Reputation: 17223
I am currently sending something like this through raw category of Postman. This works fine however I cant attach an image
{
"user" : {
"first_name": "employeeA",
"last_name": "smith",
"username": "employeeA",
"employer_image" : --->Insert image here
},
"employee_zip" : 12345
}
However I dont know how to attach the image file. I read here that I could instead use the form data category and send the image.So I did something like this
This does not work is there any way for me to select a file and then use raw json to point to that file ?
Upvotes: 2
Views: 7958
Reputation: 8660
Have you tried using a Base64 encoded string ? The final JSON object would look something like this...
{
"user" : {
"first_name" : "employeeA",
"last_name" : "smith",
"username" : "employeeA",
"employer_image" : "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII="
},
"employee_zip" : 12345
}
You can find Base64 encoder details in Mozilla Developer Website, and many implementations in Github
For testing purposes you can try first an online converter, as @MistyD suggests in the comments.
Upvotes: 1