我已经为此苦苦挣扎了几天,( fiddler 的新手)
我的网址是这样的:
mywebservice/miclaim/casedetail/GetCaseDetail/638110079?apikey=MiClaimUK&token=ZD31MsFiLrFA2hCZShBJ7i4iinqeRxfYNrIsDHWriQM=
现在这是一个多部分/表单数据内容类型,我尝试了一些方法来提交我的表单数据:(不过我提交文件没问题..它只是表单数据和文件!)
在查询中的标记内容之后添加值
LossItemId=1&Description=d&ClaimedAmount=1234.5&WherePurchased=reading&BasisOfValuation=basis&Status=sta
或者只是将它们添加到请求 header 中,但似乎没有任何效果,我仍然没有在 Controller 中获取我的表单数据值...
我认为这在 fiddler 中一定是相当明显和常见的事情,但为什么会遇到这么多麻烦?我错过了什么?
注意:我可以通过使用 html 表单的测试客户端测试我的应用程序 ..enctype="multipart/form-data"method="POST">
并且它可以工作......但不是 fiddler ??
最佳答案
不得不在其他一些问题的背景下在我的项目中重新审视这个问题..这次终于让它工作了 (对于那些可能遇到类似问题的人):
---------------------------acebdf13572468
Content-Disposition: form-data; name="ToDo"
Content-Type: application/json
{"ToDoId":32,"InstructionId":6300460,"Description":"Description","Comment":"Comment","DueDatetime":"2014-02-28T16:44:52.8140079Z","SubmittedDatetime":"2014-02-28T16:44:52.8140079Z","StatusCode":10,"Media":[{"MediaId":0,"MediaDescription":"abc","CreatedDate":"2014-02-28T16:44:52.815008Z","MediaType":"Doc","UrlPath":null},{"MediaId":0,"MediaDescription":"foo","CreatedDate":"2014-02-28T16:44:52.815008Z","MediaType":"Image","UrlPath":null}]}
---------------------------acebdf13572468
Content-Disposition: form-data; name="fieldNameHere"; filename="abc.txt"
Content-Type: text/plain
<@INCLUDE *C:\uploads\abc.txt*@>
---------------------------acebdf13572468
Content-Disposition: form-data; name="fieldNameHere"; filename="Foo.txt"
Content-Type: text/plain
<@INCLUDE *C:\uploads\Foo.txt*@>
---------------------------acebdf13572468--
关于Fiddler multipart/form-data with auth token asp.net web api 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21630811/