rkshakya99
rkshakya99

Reputation: 439

How to use postman to test formdata?

How can I use postman plugin of Google Chrome to send a FormData() object to a webapi using POST. The FormData() object has form fields personID and messageBody appended to it. I tried something like this but to no avail:

URL of the webapi: http://localhost/<<appName>>/api/v1/message

Headers:
Accept:application/json
Content-Type:multipart/form-data; boundary=---XXX---

form-data:
personID:1 (Text)   
messageBody:Hello (Text)

Upvotes: 25

Views: 84622

Answers (2)

rkshakya99
rkshakya99

Reputation: 439

Yes finally I have made it work. What I was doing wrong was not setting all the fields of the FormData() object ie, I didn't set the fields such as orderId because its value was null. When I set all the field values even if they were null, it worked. And also there was no need to set the Content-Type when you are sending a multipart/form-data...

Upvotes: 7

Abhinav
Abhinav

Reputation: 39884

Postman has a form-data POST body option that automatically does this for you.

Upvotes: 30

Related Questions