cancel
Showing results for 
Search instead for 
Did you mean: 

Send .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 

none
Template
Single File
Multiple File
Custome Code

2) Custom Code: Can someone guide how to use this option and code example of Posting xlsx file using content type multipart/form-data

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

Helpful Answers

Hi Kirtish,

The latest Utility - HTTP on Digital Exchange has action for Multipart request. Have you already considered that for your solutioning?


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

View answer in original post

9 REPLIES 9

Hi Kirtish,

The latest Utility - HTTP on Digital Exchange has action for Multipart request. Have you already considered that for your solutioning?


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

Hi @shashank.kumar280,

I have tried using ​Utility - HTTP and action HTTP Request Multipart but still facing Internal server error 500

I have passed below parameter

Address URL : [URL]
UserName:[UserName]
Password:[Password]
forcePreAuth: True

Header parameter Accepts Collection type Hence Passing below

Autharization : [Basic XXX]

FileData accepts collection type hence passing below

FileName: ""
FieldName:""
ContentType:""
FilePath : "C:\..\abc.xlsx"

After running I am getting 500 Internal server error

When I checked with API team they say they are not getting file details in the request

Also they are getting boundry as below :

multipart/form-data; boundary=boundaryboundary

Is there anything I am doing wrong ?


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

Hi Kirtish,

If forcePreAuth is set to True then the Authorization Header will be set by the utility. So can you try again without passing any Header parameter.

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

Hi @shashank.kumar280,

I tried that, I deleted everything from HEADER Collection and made it Empty and ran . Got the same error. and Header collection remains empty after the run. Is there anything else which can be of concern ?​

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

Hi Kirtish,

One other thing that I can think of is the FieldName. Currently you have set it to blank in HTTP utility. Did you set any value for "Key" under form-data in POSTMAN for this? 


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

Hi @shashank.kumar280,

Under Form-data in Postman, I have used one Key and in value I have attached .xlsx file,

As mentioned by you I used the same key in FieldName as well but the same error exists : 500: internal server error​

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

Hi @shashank.kumar280.

Issue is Resolved now. Thank you for your guidance. ​Along with the FieldName ,I added other values as well and it worked.

When I checked "Code" in PostMan I noticed there were few more parameters were being sent with request for uploading excel hence I mapped them in FileData Collection of Multipart Action as below

FileName- abc.xlsx
FieldName-FileName variable
Content-Type-application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
File path-Full file path


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

Update : Please ignore below. Issue is resolved by setting up request.timout field in code

Hi @shashank.kumar280,
Thanks for your help with this .

I have used HTTP Utility​ and It was working fine until yesterday but now it is throwing below error

Could not execute code stage because exception thrown by code stage: Object reference not set to an instance of an object.

I have passed below/attached parameter

6505.pngUpdate : This seems to be timeout error issue. It works with Smaller size. Is there any way to set timeout ?
It takes around 2 min 10 seconds before it throws an error

Also when I remove Try and Catch block , it throws below error

Could not execute code stage because exception thrown by code stage: The operation has timed out

​Could you please assist with the possible cause and if it due to timeout, can you please let me know how to increase timeout ?
Note : Working fine through POSTMAN
------------------------------
Kirtish Trivedi
------------------------------

Try out the suggestion from Bruce to increase the timeout value. Let us know if it works.

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