cancel
Showing results for 
Search instead for 
Did you mean: 

How to Pass Binary data in HTTP Body

SalmanShaik1
Level 5

Hi,

I have to make an API call which accepts the body in binary format only, so i have converted the file to binary data item using the Load Binary File action but in the HTTP action its accepting only text. Is there any other way to send the binary data in body using HTTP action except by creating a new web service in system tab?


The API is working fine If we pass the binary data from Postman.


17856.png 

17857.png



------------------------------
If I was of assistance, please vote for it to be the "Best Answer".

Thanks & Regards,
Salman Shaik
------------------------------
If I was of assistance, please vote for it to be the "Best Answer". Thanks & Regards, Salman Shaik
6 REPLIES 6

Hello Salman,

If your data is in binary format, you need to convert it to BASE64 before sending it to an API

https://community.blueprism.com/communities/community-home/digestviewer/viewthread?MessageKey=6276a0fc-04c9-4bcf-9c77-c23c6af4771d&CommunityKey=3743dbaa-6766-4a4d-b7ed-9a98b6b1dd01&tab=digestviewer

https://community.blueprism.com/communities/community-home/digestviewer/viewthread?MessageKey=73942100-2b83-4685-bb56-9433633cc1f2&CommunityKey=3743dbaa-6766-4a4d-b7ed-9a98b6b1dd01

Regards,



------------------------------
Leonardo Soares
RPA Developer Tech Leader
Bridge Consulting
América/Brazil
------------------------------
Leonardo Soares RPA Developer América/Brazil

harish.m
MVP

HI Salman Shaik,

 You can use Utility - file manipulation VBO to convert the binary to base 64  

Below is the latest VBO in the DX.


https://digitalexchange.blueprism.com/dx/entry/9648/solution/utility---file-manipulation



------------------------------
-----------------------
If I answered your query. Please mark it as the "Best Answer"

Harish Mogulluri
Lead developer
America/New_York TX
------------------------------
----------------------- If I answered your query. Please mark it as the "Best Answer" [FirstName] [LastName] [Designation] [JobTitle] [City] [State] [Phone]

Hi All,

FYI

Previously I tried all these workarounds the API is expecting only binary data. I have converted the binary to base64 but API is throwing error.

so I am checking is there a way to pass the binary data through HTTP action.

Technically binary and base64 are different? because API is not accepting base64 but if we pass binary data it's working fine.



------------------------------
If I was of assistance, please vote for it to be the "Best Answer".

Thanks & Regards,
Salman Shaik
------------------------------
If I was of assistance, please vote for it to be the "Best Answer". Thanks & Regards, Salman Shaik

@Salman 

Utility HTTP supports sending binary data in Body. Set parameters as below-

Body :  File Path with extension Eg. C:\Downloads\MyFile.xlsx
Content Type: application/octet-stream or set as required by the API
Method : POST
File URL : True



------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
------------------------------

Hi Shashank,
It worked for me, when we mention the content type as application/octet-stream it internally converts the input file of any format into binary and sends it as binary body? Then we no need to explicitly convert any file to binary using load binary action.


Do we have any documentation stating which application type should be used for which type of file/what parameters needs to be changed in HTTP request action? It would be more helpful if i have to send data in any other formats in future.

Please share if available.



------------------------------
If I was of assistance, please vote for it to be the "Best Answer".

Thanks & Regards,
Salman Shaik
------------------------------
If I was of assistance, please vote for it to be the "Best Answer". Thanks & Regards, Salman Shaik

@Salman,

Setting content-type to application/octet-stream doesn't convert file to binary. Setting the File URL parameter to True is required to deal with binary files. Description for each parameter is included in user guide.

The content-type value can be looked up from POSTMAN when you are testing the API or the third party API documentation that you are integrating with. You can learn more about mime types here https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types  



------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
------------------------------