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"

Postman 405.

I also tried /upload, but it says "bad request"

Postman 400

Asked By: VPJ

||

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.
Answered By: Milan

to run your code on postman you need to do some changes
in the header section change the

– “content-type” : “multipart/form-data”

enter image description here

and in the body section select
“form-data” : and choose file

enter image description here

Answered By: a zEnItH

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.

Answered By: Saraz
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.