cancel
Showing results for 
Search instead for 
Did you mean: 

sending .xlsx file using POST API.

kirtish.trivedi
Level 5
I have a requirement of sending .xlsx file using POST API.

I guess Ideal way of doing this is to use Single File option in WEB API configuration and passing Binary file from process.

But unfortunately the WEB API definition does not support the Binary File, even when used Binary File option from POSTMAN , it throws server error.

There are two options available it seems

1 ) Form-data : When I use this option in POSTMAN, it works fine but not sure how to use this option in Blueprism as Blueprism supports only below option

------------------------------
Kirtish Trivedi
------------------------------
1 BEST ANSWER

Helpful Answers

Hi Kirtish,

Ok, I see the HTTP VBO has been updated to include the mulitpart/form-data support. You should be able to work with this.

Try to add a line (i.e. line 3 in the screenshot below) in the code stage  of the action "HTTP Request Multipart" to set the timeout to 100000 milliseconds (100 seconds), from 10000 milliseconds (10 seconds). This should resolve your issue. You can find this Microsoft article here in relation to this property.

15525.png

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

View answer in original post

11 REPLIES 11

ewilson
Staff
Staff
Hi @Kirtish Trivedi,

Is the service that you're posting the spreadsheet something internal? Just wondering if you can work with the developer of that service to account for the file upload using the BP Web API service feature? If not, another option would be to use the Utility - HTTP VBO​ available on the DX.

Cheers,

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

bruce.liu
Staff
Staff
Hi Kirtish,

If you have a REST API endpoint that supports a single straight binary file, you can use the native Web API Services feature by setting the Body Content to Single File and then find ways to upload the file in binary format to the exposed binary parameter.

If you have a multipart/form-date involving a binary field, I am afraid you are not able to use Web API Services, neither a generic VBO like Utility - HTTP VBO to achieve this. The main reason is the data format of the Body field, is in Text/String, which is not capable of storing binary data. In the case of Web API Services feature, it would implicitly convert any binary fields to Base64 encoding, resulting in the file become not readable once uploaded by the endpoint. You must either devise a heavily customised VBO, or use a pure code stage approach to achieve this. I have created an example by using the code sample from https://briangrinstead.com/blog/multipart-form-post-in-c/ before for a customer. I have attached here for your reference. The said example works with Microsoft Cognitive Services > Analyze Image endpoint (https://westus.dev.cognitive.microsoft.com/docs/services/computer-vision-v3-2/operations/56f91f2e778daf14a499f21b) . The endpoint accepts three different types of inputs, and the example implements "multipart/form-data" specifically.

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

Thank you for response @Bruce Liu,

Unfortunately API does not supports Binary file. I went with HTTP VBO option action HTTP Request Multipart. It is working fine with Small size file but throwing error with Large file size. I will post the detailed error info in other thread

Thank you ​

------------------------------
Kirtish Trivedi
------------------------------

Hi Kirtish,

Just to be precise, API services does support binary, just not binary in a multipart/form-data body.

Also, I would ask you to check again if you have managed to achieve it using HTTP VBO. Try to access the file you have uploaded, to see if you can open it using whichever application it is designed for. I have a feeling that the file will be shown as corrupted. Successfully invoking the API endpoint does not necessarily mean the file has been uploaded correctly. This is important, otherwise you will be wasting quite a lot of time devising unnecessary workaround.


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

Hi @Bruce Liu,

Yes I am able to Upload the smaller file using newly added Multipart action of Utility HTTP.

But while uploading larger file size , it throws an error.

It throws below error
Error : 
Could not execute code stage because exception thrown by code stage: Object reference not set to an instance of an object.

When I remove the Try catch block , it shows below error 
Could not execute code stage because exception thrown by code stage: The operation Timed out

Hence I assume this is related to timeout. It takes around 2 min 10 seconds before it throws error.

Also it is working from POSTMAN hence nothing wrong from API side

Is there anything needs to be done to increase timeout limit from Blueprism or is there any other issue ?


------------------------------
Kirtish Trivedi
------------------------------

Hi Kirtish,

Ok, I see the HTTP VBO has been updated to include the mulitpart/form-data support. You should be able to work with this.

Try to add a line (i.e. line 3 in the screenshot below) in the code stage  of the action "HTTP Request Multipart" to set the timeout to 100000 milliseconds (100 seconds), from 10000 milliseconds (10 seconds). This should resolve your issue. You can find this Microsoft article here in relation to this property.

15525.png

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

Thank you @Bruce Liu,

Setting up request.timeout worked :)​

------------------------------
Kirtish Trivedi
------------------------------

@Kirtish Trivedi,

Glad to hear @Bruce Liu's suggestion has gotten you over the hurdle. I'll add an action to our backlog to update the HTTP VBO to include a configurable timeout parameter.

Cheers,
​​

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

Hi @Kirtish Trivedi @ewilson

I know the post is old but I am facing issue in uploading the xlsx file with the HTTP Request Multipart action. May I know what values needs to be added  in "FieldMetadata" collection. My "FileMetadata" collection looks like this:
15528.png



------------------------------
sushma Achar
------------------------------