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
------------------------------
37 REPLIES 37

I am trying to upload the file as form data which includes headers and other meta data
Headers:
• client-id,
• client-secret,
• x-sharepoint-username,
• x-sharepoint-password,
• x-sharepoint-site-url,
• x-sharepoint-relative-path,
• Content-Type
The file will uploaded as form data, with Key value pair,.{"file" , "uploadTest.png"}.

------------------------------
Sireesha
------------------------------

Hi Sheela,

I have had opportunities to test this extensively. But I understand this may come a bit late.

I can confirm that Blue Prism native Web Services API feature does not currently support binary data in any multipart/form-data implementation, as there exists an implicit conversion so that all binary data is converted to Base64 encoding in the process. There does not appear to be a way to override this behaviour. 

When you encounter binary data in an endpoint requires multipart/form-data, please consider the following:
  1. Do I have the option to achieve the same without using multipart/form-data? Many API endpoints do offer such flexibility, e.g. Microsoft Cognitive Services > Analyze Image endpoint.
  2. Consider use a code stage to achieve this. If you need an example of this, please see https://briangrinstead.com/blog/multipart-form-post-in-c/.

Hope this helps.

------------------------------
Bruce Liu
Senior Product Consultant, Professional Services
Blue Prism
Australia/Sydney
------------------------------

Hi @Bimal Sebastian,

Could you please  share the screenshot as I am unable to see them.

Thanks

------------------------------
Tushar Varshney
Senior Consultant - Intelligent Automation
Ernst & Young India
+91-9880188366
------------------------------
Tushar Varshney Senior Consultant - Intelligent Automation Ernst & Young India +91-9880188366

@Tushar Varshney,

I don't think Bimal is that active on the community anymore. ​I believe this is the screenshot you're referencing though:


Cheers,

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

Hi Eric,
Couldn't see the screenshot, Please share it if you have.


------------------------------
sivaranjani singaravel
Assistance Software Engineer
accenture
Asia/Kolkata
------------------------------

curl -X 'POST' \
  'https://URL/upload' \
  -H 'accept: */*' \
  -H 'Authorization: Bearer CODEOFBEARER' \
  -H 'Content-Type: multipart/form-data' \
  -F 'trust=12' \
  -F 'file=@Trust.xlsx;type=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'

------------------------------------------------------------------------

Can any one generate the template of Body content of the about API.
trust is a integers, File is a excel.

Thank you



------------------------------
Aravind kodela
------------------------------

Ernest_Christia
Level 3

I was able to send a document using multipart form, but it was by using the newer Utility - Http object.

There is a HTTP Request Multipart action in that object, and you just need to supply two collections :

  • Field Metadata
  • File Metadata

Field Metadata contains the details of the file ("name" and "value").

File Metadata would contain the actual file (enter the API's accepted field name for the file in the "FieldName" column, use the file's path in the "FilePath" column, and in the "FileContentType" you should use "application/octet-stream" in order to successfully upload the file.

Hope this would help.



------------------------------
Ernest Christian Javier
------------------------------

I have tried with the VBO:- Utility - HTTP 10.0.0, Action - HTTP Request Multipart as per the instructions in the Blue Prism community:  https://community.blueprism.com/discussion/web-api-services-to-upload-a-file-using-multipart-form-data



------------------------------
Aravind kodela
------------------------------