How to send an image to a flask server using Postman
Question:
I need to send an image file to a flask server using Postman.I did send it using a web browser and “render template”.But when i tried the same program with postman it showed "method not allowed"
.
I also tried /upload, but it says "bad request"
Answers:
To make this work you’ll need this:
- add upload in your URL in postman.
- add header Content-Type multipart/form-dataitem
- enter file as key for row in form data where you choose your file. On the screenshots I see that it is empty.
I had the same issue testing flask API with file upload in postman. I was passing both String data and Image file in one flask API.
Tried Content-Type = multipart/form-data
and Content-Type = application/json
but it didn’t work.
Resolved it by removing all Content-Type
headers. Strangely it works that way.
Hope this helps if anyone stuck in the similar issue.
I need to send an image file to a flask server using Postman.I did send it using a web browser and “render template”.But when i tried the same program with postman it showed "method not allowed"
.
I also tried /upload, but it says "bad request"
To make this work you’ll need this:
- add upload in your URL in postman.
- add header Content-Type multipart/form-dataitem
- enter file as key for row in form data where you choose your file. On the screenshots I see that it is empty.
I had the same issue testing flask API with file upload in postman. I was passing both String data and Image file in one flask API.
Tried Content-Type = multipart/form-data
and Content-Type = application/json
but it didn’t work.
Resolved it by removing all Content-Type
headers. Strangely it works that way.
Hope this helps if anyone stuck in the similar issue.