Extract file from API response

Hello everyone,

I am working on an API which gives me response in octet stream(application/octet-stream).

Now, I need to convert this octet stream to a byte array to later save it locally. The problem is it’s not a base64String. I know we can convert base64String to byte array easily but I do not know how to convert this octet stream to byte array. My goal here is to get the file from the API and save it locally on my system.

Any help would be highly appreciated.

Thank you,
Himanshu

@Himanshu_Punj
welcome to the forum

can you try file writing like:

System.IO.File.WriteAllBytes(YourPath, YourPDFData);

How is the API invoked / called within UiPath?

Hi @ppr

I understand that part but what I do not is to convert the API response to Byte array so that I can use the method you pointed out.

FYI - I am using HTTP Request activity. Whenever I try to convert the API response to base64string using - Convert.FromBase64String(), I get an error - The input is not a valid Base-64 string as it contains . . .

I think that happens because the API response is not a base64string, it is an octet stream.