Tring to upload a file to a Storage Bucket per Rest api

Hi

As mentioned in the title my target is to upload files to a storage buckets per rest api.

I have found a really useful topic here: Orchestrator API - Buckets - #8 by codemonkee

i am tring to call the method /odata/Buckets({key})/UiPath.Server.Configuration.OData.GetWriteUri but I encontered some problem with the “path” parameter:

I cannot understand hot to fill this parameter. Do you have some examples or references?
as a “Blob” do i need to provide the fullpath (for example c:/temp/test.txt) in binary format?

Thank you in advance

Hi @Mi_Pi

To upload a file to a Storage Bucket using the Rest API in UiPath, you can use the “HTTP Request” activity to send a PUT request to the bucket’s endpoint. In the request, you can include the file as the body of the request and set the appropriate headers, such as the “Content-Type” and “Content-Length” headers.

Here is an example of how you can do this in UiPath:

  1. Drag and drop the “HTTP Request” activity into your project.
  2. In the “Method” field, select “PUT”.
  3. In the “Uri” field, enter the URL of the Storage Bucket endpoint, including the name of the bucket and the file you want to upload. For example: https://endpoint_url/
  4. In the “Headers” field, add the “Content-Type” and “Content-Length” headers and set their values to the appropriate values for the file you are uploading.
  5. In the “Body” field, select “File” and then browse for the file you want to upload.
  6. Click “OK” to save the activity and run your project.

This should upload the file to the Storage Bucket using the Rest API. Keep in mind that you may need to authenticate your request using a service account or other authentication method, depending on the security settings of your Storage Bucket.

Hi @Kaviyarasu_N

Thank you for your quick reply.

first of all , how can I get the storage bucket endpoint?

As I understand from here(Orchestrator API - Buckets - #8 by codemonkee) I need the make 2 rest request, the first of all a “GET” requestr where I get the uri as a Response and then the PUT request.

I am still blocked on the GET request and my question is what do I need to insert in the “path” parameter and in which format.

Thank you

@Mi_Pi
Yes, you got it right.
In the first call, the mentioned Path is the Path within Storage Buckert where you want to place the file

We would also recommend to explore / protoype in swagger when more options are to explore for the first next steps

1 Like

Check if this article is helping you https://uipath-survey.secure.force.com/CaseView/articles/Knowledge/How-To-work-with-Orchestrator-Storage-Buckets-in-Studio?lang=en_US

Hi @ppr

I have tried to prototype my requests in Swagger and also thanks to the article posted by @marian.platonov (thank you!) I have build sucessfully the get request for the writeUri.

Now I am struggling with the PUT request:-).

the put request should contain

  • the Uri from the writeUri get request
  • the file in binary format as body
  • in the header: the keys and values contained in the previous get request (something like “x-ms-blob-type”:“BlockBlob”)
    -the authentication

do I miss something?

when I tring to send the PUT request I receiv alwas the following error:

HTTP Error 411. The request must be chunked or have a content length.<

I already tried to add the content-lenght in the header but without success.

Any ideas?

thank you

It would be helpful for others, if you include details on exactly how you are making the calls. Are you just testing with Swagger? Using Postman? Some Programming/Scripting language: PowerShell, C++, Python, Javascript, etc.?

If you can provide what you are doing, it’s easier to identify the culprit.

  • Steps / Actions / Code
  • Request Body/Headers (Sensitive information masked)
  • Response Body/Headers (Sensitive information masked)

Content-Length Header is the size of the request body in bytes - Are you calculating this manually, or is what you are using this providing it for you?

Hi @codemonkee

I use Talend to make the request. It is a java based tool for ETL processes.

the request is the following:

Address: https://cxxxxxxstg.blob.core.windows.net/orchestrator-507188888-3181-4f5e-894p-55dbdfcaf312/BlobFilePersistence/5be32ddd-0e99-4a2f-b485-c8019c09e3fe/ScreenshotsBucket?sv=2021-08-06&st=2022-12-16T08%3A07%3A33Z&se=2022-12-16T08%3A11%3A03Z&sr=b&sp=cw&sig=65d3b0uaH2KTqeeDLDfLXDTJ1grcO%2Byv0he8mK0LWOY%3D
Http-Method: PUT
Content-Type: text/html
Headers: {Content-Type=[text/html], Accept=[/], x-ms-blob-type=[BlockBlob], Content-Length=[14], Authorization=[Bearer xxxx]}

response:

esponse-Code: 411
Encoding: US-ASCII
Content-Type: text/html; charset=us-ascii
Headers: {connection=[close], Content-Length=[344], content-type=[text/html; charset=us-ascii], Date=[Fri, 16 Dec 2022 08:08:03 GMT], Server=[Microsoft-HTTPAPI/2.0]}
Payload: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>

the content-Lenght is automatically calculated by the etl process. Before the request the job calculates which is the size in bytes for a specific file.

I hope it helps

Thank you!

  • after calling the method /odata/Buckets({key})/UiPath.Server.Configuration.OData.GetWriteUri comes back the uri link for the direct upload.
  • the PUT request required any authentication in the header.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.