Doing an api request to add a file to bucket with CURL

Hello!
Making upload form of a file from web service to orchestrator bucket. (using PHP + CURL)

For first i got a dynamicly generated link to upload with GET request:
odata/Buckets(1)/UiPath.Server.Configuration.OData.GetWriteUri?path=\&expiryInMinutes=5

So - to upload file to a bucket i need to make a PUT request to link, that i got with previous one.

file is in $_FILES, and formated to object with CURLFile function and attached to POSTFIELDS of curl request.

The problem → nothing happening.
The response is:

What am I doing wrong? The file is in the correct destination. How i can set this path?

The code is bellow:

I also tried to change content-type to multipart/form-data and add “” symbol to third argument - nothing changed.
The dynamic link is absolutely correct too.

Hope for help. Thank you.

Also tried this - same result.

upd.

Finally made it. Not without UiPath TechSup :grinning:

This is the correct method to upload:

  1. Creating a temporal link, with an api get request where path parameter is a NAME of file, that you want to see in orchestrator storage bucket (this is the spot where i failed - thought that this parameter is a prefix folder where i want to place it);
  2. Using this CULROptions to attach file and execute the request, where $uploadfile is a path of your file at server (machine where the service is living):
    curl_setopt_array($curl, array(
    CURLOPT_URL => $answer[Uri],
    CURLOPT_UPLOAD => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_BINARYTRANSFER => true,
    CURLOPT_SSL_VERIFYHOST => false,
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_ENCODING => ‘’,
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_PUT => true,
    CURLOPT_INFILE => fopen($uploadfile, ‘rb’),
    CURLOPT_INFILESIZE => filesize($uploadfile),
    CURLOPT_HTTPHEADER => array(
    “Content-Type: application/json”,"Authorization: Bearer ".$neededtoken
    )
  3. Executing.
  4. PROFIT.

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