Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Http 使用文件和xml内容发出POST请求_Http_Asp.net Web Api_Fiddler - Fatal编程技术网

Http 使用文件和xml内容发出POST请求

Http 使用文件和xml内容发出POST请求,http,asp.net-web-api,fiddler,Http,Asp.net Web Api,Fiddler,我正在尝试向api服务器发出POST请求 我有一个请求主体,它是一个xml参数: <create-user> <user-name>username1</user-name> <password>password1</password> </create-user> 用户名1 密码1 在这个参数旁边,我还需要发送一个文件 我用fiddler尝试了以下方法,但是服务器没有接收到数据(文件存在,但是参数不存

我正在尝试向api服务器发出POST请求

我有一个请求主体,它是一个xml参数:

<create-user>
    <user-name>username1</user-name>
    <password>password1</password>
</create-user>

用户名1
密码1
在这个参数旁边,我还需要发送一个文件

我用fiddler尝试了以下方法,但是服务器没有接收到数据(文件存在,但是
参数不存在)

是否可以将xml参数与上载的文件一起发送


是。只需在xml正文前添加边界标记(和“内容类型:应用程序/xml”),如下所示:

------yxz
Content-Disposition: form-data; name="formInputXML"
Content-Type: application/xml

<create-user>...</create-user
------xyz
Content-Disposition: form-data; name="formInputFile"; filename="UserData.xml"
Content-Type: text/xml

<UserData.xml content>
------xyz--
----yxz
内容处置:表单数据;name=“formInputXML”
内容类型:application/xml
...