Unable to request multipart/form-data POST API in UiPath

Hi UiPath experts,

I need to setup a POST API call within my UiPath script. I have tested this POST request via POSTMAN and I am able to get a successful response. I have pasted the screenshots of POSTMAN below.

However, no matter how I try to setup the body in UiPath, I keep getting below error.

To pass the jpeg file in UiPath, I used some other advice and used below 2 lines to first convert it into a binary string.

Assign bytearray = File.ReadAllBytes(“filepath”)
Assign binarystring = Convert.ToBase64String(bytearray)

Then I’m trying to pass document = binarystring. Tried doing it inside “body”, “attachments”, “parameters”, none of it works - I still get below error. Anyone knows how to solve this please? Thanks!

{“result”:“error”,“code”:100000,“errors”:[{“classification”:“DeserializationError”,“message”:“no multipart boundary param in Content-Type”},{“fieldNames”:[“document”,“url”],“message”:“Please provide either a document or a URL.”}],“request_id”:“Ay0AXP6TeUgMUuXcWg4YwStVMqQNBftp”}

Hi, would be better if you show us how your are trying this in uipath…

Hi @bcorrea, thanks for the reply!

I am attaching what I’ve tried in UiPath, trying to mimic the POSTMAN exactly. Please add UiPath Web Activities package if you have not already. POST API.xaml (7.5 KB)

Just to add, this is me trying to pass the binary string as a key value for “document”, inside the parameters under the HTTP request. Other than this, I also tried passing the binary string as an attachment in the HTTP request, but still get the same error.

The error is the response I pasted above: {“result”:“error”,“code”:100000,“errors”:[{“classification”:“DeserializationError”,“message”:“no multipart boundary param in Content-Type”},{“fieldNames”:[“document”,“url”],“message”:“Please provide either a document or a URL.”}],“request_id”:“Ay0AXP6TeUgMUuXcWg4YwStVMqQNBftp”}

Hi All,

Is anybody able to help check what I did wrong please? Thanks!

see an example discussion about your problem:

Hi @bcorrea, thanks again for the pointer.

I’m confused after reading this discussion. Is it suggesting that I add additional boundary info under header key “Content-Type”? But when I setup the API in postman I did not need to do that (shown in screenshot above).

I also managed to obtain the code to use in JS/Python to get this API to work, and it seems like there is no boundary info there either. Am I understanding this wrong?

Thanks for helping me with this!

image

i dont know python libraries, but it could have boundaries being set internally…