Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload image using raw in POSTMAN?

I am trying to upload an image using POSTMAN. I succeed with form-data but not with passing data in raw JSON format.

request through form-data in POSTMAN:

enter image description here

request through curl:

curl -X POST -H "Content-Type:multipart/form-data" -F "profile_image=@/home/shivani/Pictures/Wallpapers/8018.jpg" http://127.0.0.1:8000/api/users/1/image/
{"message":"Image Uploaded successfully.","profile_image":"http://res.cloudinary.com/aubergine-solutions/image/upload/v1430204993/w0oxhv6beaxd14twrxmi.jpg"}~ 

When I send request in raw as:

enter image description here

I get the following error though i have added MultiPartParser in Django settings:

enter image description here

Can anybody help to solve this problem?

like image 849
Shivani Sharma Avatar asked Apr 28 '15 09:04

Shivani Sharma


People also ask

How can I upload raw data to Postman?

Use Postman In Postman, create a new PUT request and include your newly created API call in the request. On the Body tab, and select binary. Select the file you would like to upload. Click Send.

How do I get an image to respond to a Postman?

You can also place your cursor in the response and select ⌘+F or Ctrl+F. This option isn't available in a response's Preview or Visualize views. Note that if the response's Content-Type header indicates that the response is an image, Postman will detect and render the image automatically.


1 Answers

When i'm using the image upload, i encoded the image using base64,and that encoded string is passed as json string.In the backend we can decoded the string and make the image.Try this, i think it works.

like image 150
Ferose Avatar answered Sep 21 '22 07:09

Ferose