在我的WebApi项目中,这是我的当前
http://localhost:52494/api/v1/Register/RegisterUser
参数是模型:
public class DataUserModel
{
public string Gender { get; set; }
public int PhoneNumber { get; set; }
public byte[] ProfileImage { get; set; }
}
如何设置Postman以二进制图像发送此请求,其他属性为JSON!我通常会这样做:
Content-Type:application/json
{
"Gender":'F',
"PhoneNumber":99999999,
}
答案 0 :(得分:3)
你基本上有两个选择:
查看http://blog.marcinbudny.com/2014/02/sending-binary-data-along-with-rest-api.html它详细描述了两种情况。
在Postman(伪代码)中你会得到如下内容:
POST http://localhost:52494/api/v1/Register/RegisterUser HTTP/1.1
Content-Type: multipart/form-data; boundary="01ead4a5-7a67-4703-ad02-589886e00923"
Host: 127.0.0.1:53908
Content-Length: 707419
--01ead4a5-7a67-4703-ad02-589886e00923
Content-Type: application/json; charset=utf-8
Content-Disposition: form-data; name=imageset
{"Gender":"F", "PhoneNumber" : 99999999}
--01ead4a5-7a67-4703-ad02-589886e00923
Content-Type: image/jpeg
Content-Disposition: form-data; name=image0; filename=Small-Talk-image.jpg
{YOUR IMAGE CONTENT HERE}
--01ead4a5-7a67-4703-ad02-589886e00923
Content-Type: image/jpeg
Content-Disposition: form-data; name=image2; filename=url.jpg