cancel
Showing results for 
Search instead for 
Did you mean: 

Send Document using Multi Part Form Data in Web API

AmbrishSrivasta
Level 2
We are trying to consume a webservice which take a document and other metadata using multi part form data Content Type.
We are able to call the service successfully using Postman, but when using Web API feature of Blue Prism latest version 6.5 we are having following observations.
1. When using Template dropdown option in the Request, it is sending the whole data in json format instead of multi-part form data as expected by the service.
2. When using Single or Multi File option, we do not see a way to send additional attributes in the body as expected by service
3. We also wrote a custom code to send the information using multi-form, but even that ended up sending information in raw format.

Any experience on above requirement?

------------------------------
Ambrish Srivastava
Architect
Persistetnt Systems Inc
America/New_York
------------------------------
1 BEST ANSWER

Helpful Answers

ChrisHogan
Staff
Staff
I have successfully used the Web API to invoke this Microsoft Form Recognizer service that required multi-part form data as a payload.
https://westus2.dev.cognitive.microsoft.com/docs/services/form-recognizer-api/operations/AnalyzeWithCustomModel

The Body Content of the Request was "Multiple Files" and the Collection Parameter Name was "Files"

The Request Header contained "Content-Type" and a value of "application/pdf"

The Web API action was passed a collection called "Documents"  that had the following structure:
26425.jpg
I have not tried a scenario where any additional information was needed in the Request Body.


------------------------------
Chris Hogan
Senior Ecosystem Architect
Blue Prism
America/Chicago
------------------------------

View answer in original post

37 REPLIES 37

ChrisHogan
Staff
Staff
I have successfully used the Web API to invoke this Microsoft Form Recognizer service that required multi-part form data as a payload.
https://westus2.dev.cognitive.microsoft.com/docs/services/form-recognizer-api/operations/AnalyzeWithCustomModel

The Body Content of the Request was "Multiple Files" and the Collection Parameter Name was "Files"

The Request Header contained "Content-Type" and a value of "application/pdf"

The Web API action was passed a collection called "Documents"  that had the following structure:
26425.jpg
I have not tried a scenario where any additional information was needed in the Request Body.


------------------------------
Chris Hogan
Senior Ecosystem Architect
Blue Prism
America/Chicago
------------------------------

Hi,

If this issue is still open, i have got Multi Part form data working using templates. refer the attached image.,

26426.png


------------------------------
Bimal Sebastian
Consultant
Blueprism
Asia/Kolkata
------------------------------

Thanks Bimal, I was able to consume services as suggested by you.

------------------------------
Ambrish Srivastava
Architect
Persistetnt Systems Inc
America/New_York
------------------------------

Hi,

Do we have to split the input file into multiple parts?

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

Hi Shashank,

You dont need to split the file into multiple parts. Multi Part form data is one way to send information using http. In this mode you can send a file and additional information along with the files binary data, hence the term Multi Part.
If you only have a file to send and no additional meta data, then you can chose existing file or multiple file api type in blue prism, provided the api you are consuming supports it.
If the API you consume requires multi-part form data, then you will need to try the above method.


------------------------------
Bimal Sebastian
Consultant
Blueprism
Asia/Kolkata
------------------------------

Hi Bimal,

What does the [boundary] stand for?

------------------------------
Bryan Jay
------------------------------

Hi Bryan

In http, a multi part form data is characterized by using a boundary value to separate each form set.
Here [boundary] is a parameter that can be customized and added to the body.

There is no harm, if you chose to not customize it. You can tweak the template and hard code any text value in place of boundary.

Thanks
Bimal

------------------------------
Bimal Sebastian
Consultant
Blueprism
Asia/Kolkata
------------------------------

Hi there Chris,

I know this thread is a little old now but I have come across this and wonder if you could help.

I'm trying to get data into the "Documents" collection, but seem unable to. I have my 2 files which I need to send via API in a collection.

26432.png

But seem unable to get them from that to a collection with a binary value.

How did you get the documents into a collection with a binary value?

Thanks
Matthew


------------------------------
Matthew Ross
Principal Innovation Developer & Analyst
NHBC
Europe/London
------------------------------

Any help with my query would be great if anyone knows 🙂

------------------------------
Matthew Ross
Principal Innovation Developer & Analyst
NHBC
Europe/London
------------------------------