01-12-23 09:45 AM
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.
02-12-23 10:46 PM
Hello Salman,
If your data is in binary format, you need to convert it to BASE64 before sending it to an API
Regards,
03-12-23 04:17 AM
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
03-12-23 05:21 AM
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.
04-12-23 04:23 AM
@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
04-12-23 01:58 PM
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.
05-12-23 03:56 AM
@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