postman

How to send a base64 image in Postman?


Need to make a request to an API with a image encoded in Base64, the request is a put, and i was trying making in the body section using the raw format and adding i.e. this JSON:

    {
     "picture": {
        "name": "/Users/Cokeina/Desktop/imagenes/default_avatar.png",
        "content_type": "image/png",
        "file": "base64string"
     }
    }

but seems like this isn't working, what is the correct way to do this?


Solution

  • You could find online Base64 image encoder. They encode an image to a string. The example of raw body in JSON format in the Postman

    "profile": {
        "first_name": "John",
        "last_name": "Dow",
        "photo": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII="
    }
    

    I think, that "name" and "content_type" is obvious in your JSON.