Postman Response format from RAW to Base64

I’m receiving the response from an API using java, and I’m receiving ‘Raw’ format type as the response. However when I’m using Postman, I’m able to receive the response in 3 formats and able to switch between the formats. Attaching the screenshot.

I need a solution for changing the response type and to receive the response in Base64 format using the Java code.

Hey @epraj94 :wave:

Welcome to the Postman Community! :postman:

What content-type header are you setting in the code? Are you setting a base64 header?

The response in Postman would be based on the response header from the endpoint.

Before I didn’t mention the content-type, now I have added content-type as base64, hence receiving the same response. I tried in my java code as well, still receiving the RAW data.

Wouldn’t you need to add that header to the implementation so the server knows that the response should server it as that content type?

What are the response headers for your request?

these are the response headers for my request.

Hey @epraj94, the API you are calling is returning the response in that format. Is that an API you created? If so, you would need to update the implementation to return the binary data as base64 encoding.

If you don’t own that API, maybe you can look at the docs and see if they have a flag or parameter you can provide to change the response type.

Hey @epraj94 , From your response Header it seems like you are receiving image/jpeg. I dont think you can convert or validate the received raw image content.

Please elobrate on what exactly you are looking for.

I need to download the data in Base64 format

I don’t want to leave you without an answer, @epraj94. Could you answer my questions from a few days ago so we can get you past this?

I don’t own that API. Its an external API, and I’m consuming that API. I have also checked the docs, where they were not having any flags to change the format type. It seems I need to download the data as a file and convert it into Base64 format.

1 Like