Reputation: 715
In my WebApi project, this is my Current
http://localhost:52494/api/v1/Register/RegisterUser
And the parameter is a model :
public class DataUserModel
{
public string Gender { get; set; }
public int PhoneNumber { get; set; }
public byte[] ProfileImage { get; set; }
}
How to set up the Postman to send this request with a binary image and the others properties as JSON! I usually do :
Content-Type:application/json
{
"Gender":'F',
"PhoneNumber":99999999,
}
Upvotes: 1
Views: 2392
Reputation: 1103
You basically have two options here:
Have a look at http://blog.marcinbudny.com/2014/02/sending-binary-data-along-with-rest-api.html it describes both scenarios in detail.
In Postman (Pseudo Code) you would have something like the following:
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
Upvotes: 3