Form-Data in not working

I’m facing some problem when using postman. When I’ll try to send raw data in JSON(application/json) format, it get success.

but But when I’ll try to send form data it returns some error.

@spacecraft-explorer Welcome to the Community :partying_face:

Developer would have designed few things, and the API will work that way. Only if your API supports form data you can send the data through it. So if the raw format is working fine, may I know the purpose of using the form data here? Also generally for form data, even the content-type will be like “multipart/form-data” (sample value) , again it should be mentioned clearly in the API documentation.

If your API supports form data for POST request, please check the header values and try again :blush:

i want to upload picture with this data… So I use form-data. but getting validation failed error

Thank for welcoming me…!!!

1 Like

@spacecraft-explorer Yes bad request is something wrong with the data sent as part of your body. Means the API is not able to handle it when you do it via form data. Also is it mentioned somewhere that your API is capable of handling the images as part of the body?

Hi @spacecraft-explorer

Can you please try to check raw data in console and see if there are any differences using raw and form data?

I have the same problem , form-data not working

Same issue here, form-data is not being sent correctly by postman, i have tested an actual form submitting the data and I have to use RAW/JSON and I have to use a model in my action controller (rather than the single param I want).

I just want an ID - so now I have the additional memory space and GC per session of a DATA class with string ID {get;set;} in it.

Form data is not working in my case and i need the form-data because i need to upload and image which is not possible with x-ww-form-urlencoded or raw. So what can i do?

Try using multer as a middleware… I was facing the same issue but after adding multer it was sorted and i am able to use form-data with put as well as post requests.

I got the same problem.

The Headers is application/json; charset=utf-8 for the request.
It should be multipart/form-data; boundary=.

photo as below

Hey @cryosat-astronomer-9 :wave:

Welcome to the Postman community :postman:

That’s a response header coming from your server, which is also throwing a 500 error.

This is kind of like a black box at the moment because no really knows the implementation of your server so this is just 2 screenshots showing some request / response headers. You would need to provide more information and context for anyone to help here.

This also doesn’t feel like a Postman specific issue and more to do with the implementation of your server code.


Adding this here as I seen the question has also been asked on SO: