cancel
Showing results for 
Search instead for 
Did you mean: 

Error while upload a file with API using multipart form data

michael.krey
Level 3

Dear community,

 

I'm try to upload a document in a third party API.

My problem is, that I get these error when I try to send the request out of Blue Prism.

13572.jpg

 

In Postman I'm able to upload the file with a PATCH request.

This is how I build the request in Postman:

13573.jpg

And these are my settings in Blue Prism:

13574.jpg
13575.jpg
13577.jpg

 

I load the file in a binary data item with ‚LoadBinaryFile([Pfad Anhang])'.

13578.jpg

 

I've tried to use the body content ‚single file' as in the bpdocs suggested. But the API needs the field ‚meta', so I have to set the body contet as template.

 

I also found out that if I leave the data item fort he file empty, the request is succesful. But of course no file is uploaded.

 

Can somebody help me with that issue?

Thanks a lot
Michael



------------------------------
Michael Krey
RPA Consultant
providata GmbH
Freiburg
------------------------------
1 BEST ANSWER

Helpful Answers

@Michael Krey @ewilson

I had a similar issue earlier with another api. It might help to add HTTP header that calls out that the data is Base64 encoded .
See highlighted in red below.
​13546.png​

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

View answer in original post

9 REPLIES 9

steven.boggs
Staff
Staff
Hi Michael,

We've seen this scenario (a 500 error when uploading multi-part data) in the past with customers integrating Blue Prism with Appian. The issue is usually related to how Blue Prism transmits the body of the JSON file.

While you may not be using Appian in particular, this KB article may be of some use. It suggests to inspect the JSON file being transmitted by Blue Prism to check if the data is being passed in a collection or not, and adjust the endpoint to allow for (Content) -- i.e. a Collection in a single item, if possible.

------------------------------
Steve Boggs
Senior Product Support Engineer
Blue Prism
Austin, TX
------------------------------

ewilson
Staff
Staff
Hi @Michael Krey,

One other thing to consider is whether you need to Base64 encode the binary data before attaching it to the form submission. This is quite often the case. If you have Fiddler you can capture the Postman an BP submissions and compare the contents of the submissions to see how they differ.

Cheers,
​

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

Hi @Eric Wilson,

 

thanks for your advice with Fiddler. By analyzing the submissions I found out that one problem was with the boundary. Now I put in the boundary via parameters and not the request works without an error. Unfortunately the file is still not uploaded.

Here are my analysis oft he submissions.

It seems to me, that the file contend in the BluePrism submission isn't shown or translated correct. Could this be what you've mentioned about the Base64 encoding? If yes, how I can encode the file?

Thanks for your help and best regards

Michael



------------------------------
Michael Krey
RPA Consultant
providata GmbH
Freiburg
------------------------------

Hi @Michael Krey,

From the attachments it shows that Postman is attaching the PDF to the request as raw binary data whereas the Blue Prism request is attaching data to the request in base64. So something is being sent, but it isn't being processed by the server because the server is expecting a PDF (based on Content-Type: application/pdf) whereas the content it's receiving encoded.

You're still using the same Web API that you showed in your original submission, correct? So you're passing the PDF into the request as a binary data item named Datei?

Cheers,​

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

Hi @ewilson,

yes I'm still using the same Web API, that's correct. And I use the data item 'Datei' to pass the PDF.
In my corresponding object I load the file with 'LoadBinaryFile' and pass it in the API.

Best regards,
Michael
​

------------------------------
Michael Krey
RPA Consultant
providata GmbH
Freiburg
------------------------------

@Michael Krey,

One issue I see is that your ending [boundary] needs to have two dashes at the end (ex. ​------WebKitFormBoundary7MA4YWxkTrZu0gW--). The two dashes at the end notify the receiving server that it's the final boundary of the upload (i.e. end of the request). So in your Web API definition you could change that part of the template to look like this [boundary]--.

I'm still not sure why the data represented in the two captures looks different though. Did you pull both of these from Fiddler or did you grab the Postman capture directly from Postman? I've checked with engineering and they said they do not Base64 submissions within the product.

Cheers,

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

@Michael Krey @ewilson

I had a similar issue earlier with another api. It might help to add HTTP header that calls out that the data is Base64 encoded .
See highlighted in red below.
​13546.png​

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

@ewilson @shashank.kumar280

Thank you very much for your help. Finally it works. You really made my day!

Best regard
Michael​​

------------------------------
Michael Krey
RPA Consultant
providata GmbH
Freiburg
------------------------------

Leave it to @shashank.kumar280 to save the day. 😂

Cheers,
​

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------