Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to post file along with json data in Postman?

Tags:

json

postman

I know how to post json and I know how to post file in multipart form in Postman. But how can I do both together. For example:

Here is my jason to post:

{
    "title": "Post title yeah",
    "body": "My first post body"

}

So how can I post image.jpg located at /home/me/Desktop along with the the above json?

UPDATE: Note that I want so send file using JSON, so my question is different from this which is about multipart form sending using Postman.

like image 712
Karlom Avatar asked Jul 15 '17 19:07

Karlom


1 Answers

You can use this online tool to convert your file to a base64 (https://www.browserling.com/tools/file-to-base64), then you can send it as part of the json. I reduced the size of the base64 string for the answer.

{
    "title": "Post title yeah",
    "body": "My first post body",
    "image": "JVBERi0xLjQKJeLjz9MKMiAwIG9iago8PC9MZW5ndGggMjcyNS9GaWx0ZXIvRmxhdGVEZWNvZGU+PnN0cmVhbQpYCb1c247byBF9X8D/0MC+JIFNs5t9IY0gwHicXRjI2GOPvPsQ5EGrocdKRGmiofby9+kmu5t901BFKoLhi8qqc04Xq07zZr/47r8olz84JlmORKV+3dfoZ7R9If8GcxVkeUZLjijNBEOYZhgT+523C/T6hwJVWVVVaPG1w5IID4gxluESLf6BMMuqkkqYImOMoMU9+tPH/X29R9+/+TNa/Bst/oL+vnjx3aeBkJcZqwQilfwwnU/gjFe843u3bOuYjHcLUstjVYlwgfX6cp+NJtgoI5no6RQKKSWMTGQ9HaG4EDzio2o9QshqckkjMklGMsJAbAqjIBKlyHJOO7acvCb8NcnlFzB7g+kbUqbrykUla0kR491CeVZFdcV4vLC8JFlJy477bre5R4v"
}

enter image description here

like image 150
Fidel Garcia Avatar answered Oct 01 '22 23:10

Fidel Garcia