cancel
Showing results for 
Search instead for 
Did you mean: 

BOX API Upload

matthew.cable
Level 5

Hi 

Please can I have some assistance with regards to uploading a document to Box via an API.

Currently our API's go through Mulesoft, I have managed to create API's in Blue Prism to Search, Delete Folder, Delete File, Get folders etc... However I can get the Document Upload request to work.
This is working in Postman, but I am unsure how to move this into Blue Prism. We are using Basic Access which works fine.

I have done all of it so far via Web API Services and would like to keep the upload in that part also

I have attached a file with what postman looks like and from BOX what they require.

Thank you



------------------------------
Matthew Cable
Consultant
Zurich
Europe/London
------------------------------
39 REPLIES 39

@Matthew Cable

In the HTTP VBO, try adding System.Web. in front of MimeMapping. The end result would look like this: System.Web.MimeMapping.GetMimeMapping

I'll spend some time today looking at the template body for your Web API implementation.

Cheers,



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

@ewilson 

Thank you for the help, I have amended the code and I still see the same error message

22816.png

22817.png



------------------------------
Matthew Cable
Consultant
Zurich
Europe/London
------------------------------

@ewilson 

Thank you very much for your help



------------------------------
Matthew Cable
Consultant
Zurich
Europe/London
------------------------------

Good morning @ewilson 

Do you have any update on the above please?

Thank you

Matt



------------------------------
Matthew Cable
Consultant
Zurich
Europe/London
------------------------------

Hi @Matthew Cable

Apologies for being out of touch on this. In your tests, do you know the size of the files you've been working with? The reason I ask is that the Box API has two different upload actions depending on the size of the file. If it's less than 50MB, it's a straight upload. If it's bigger than it needs to be a chunked upload.

Cheers,



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

@Matthew Cable

FYI - I got a simple Web API example working with a Template body. The issue with using a template though is that it won't allow you to properly handle situations where you need to upload a file larger than 50MB and have to chunk it. For that reason, it's probably best to implement at least that part in a VBO. Let me know your thoughts and we can whip something up. 

NOTE: The key here is getting the boundary definition correct. Whatever boundary you define in the Content-Type header (ex. ---ABC), you have to make sure you add 2 additional dashes at the front of the boundary when you actually use it in the body. This is from the specification. So in the example about I would create a Content-Type header that include multipart/form-data; boundary=---ABC ( notice there are 3 dashes). When I actually use this boundary in the body, I would define it as -----ABC (5 total dashes). End the end boundary would be -----ABC--.

Here's some screenshots from the template example:

22908.png

22909.png

22910.png

22911.png

22912.png

22913.png

Cheers,



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

Hi @ewilson 

Thank you very much for the above, sorry for the delay, i was off last week.

I have replicated on what you have mentioned above, however i am still receiving a 400 Bad Request error.

22935.png

22936.png

22937.png

Please can you have a look to see if there is anything I am doing incorrectly.

Thank you



------------------------------
Matthew Cable
Consultant
Zurich
Europe/London
------------------------------

Hi @Matthew Cable

I'm traveling for meetings this week, so not as active on the Community. I've attached a .bprelease that contains the test Web API Service that I put together. You might try importing and testing it in your environment. The only thing I can think of is that maybe Box is not happy with the Folder ID you're providing. In my tests I've used 0 as the Folder ID which basically says to upload the file to the root of the account tied to the authentication credential.

Cheers,



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

Hi @ewilson 

Thank you very much for the support, this has worked. 🙂

From what I can see the only difference between our two was the Boundary.
I have also had to upload via Binary and use the Encode 64 but this works fine.

Thank you for all your help.
Matt



------------------------------
Matthew Cable
Consultant
Zurich
Europe/London
------------------------------

@Matthew Cable

Glad to hear it worked for you. Keep in mind that if you need to upload files larger than 50MB there's a completely different endpoint for that. Larger files require the use of an upload session and chunking with the Box API. You won't be able to do that with a Web API though. It will have to be a in a VBO.

Cheers,



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