How to add files to AI Center Dataset using REST API requests and Postman?

  1. The Dataset we want to manipulate needs to be set as public:

  2. An external application must be created in order to retrieve Bearer Token for Cloud Access. You can follow the steps here. The needed scopes to be checked for this specific use case are:

  3. Once we have the refresh token on hand, we can construct our endpoint. Using the url given in Dataset as an endpoint, remove “public” before ?blobname
    and add the full encoded path within the dataset, including the file extension. For example, if I need to add Picture.jpeg to: images/AAA path


    I need to encode the path as:

    %252{images}%252{AAA}%252Picture.jpeg
    

    In my use case, I needed to upload images, but other kind of files are accepted too:

    curl 'https://cloud.uipath.com/{OrgName}/{TenantName}/aifabric_/ai-trainer/v1/signedURL?blobName={BlobPath}%252{Folder}%252{Subfolder}%252Picture.jpeg&signingMethod=PUT&encodedUrl=true' \
    --header 'Authorization: Bearer {Token Retrieved at step 2}
    
  4. Using the response at step 3, which will look like this:

    {
        "respCode": 200,
        "respMsg": "OK",
        "data": {
            "signingMethod": "PUT",
            "url": "https://aifproddatawetraining.blob.core.windows.net/training{some info}%2F{Folder}%2{Subfolder}%2FPicture.jpeg?sv={some other info}&rsct=application%2Foctet-stream",
            "contentType": "application/octet-stream",
            "authRequired": false
        }
    }
    

    Copy the url from “data”/“url” and add “x-ms-blob-type”: “BlockBlob” and construct the final request for adding files to the needed Dataset. For images, I needed to set body type as binary:

    curl --request PUT 'endpoint retrieved from "data"/"url" ' \
    --header 'x-ms-blob-type: BlockBlob' \
    --header 'Content-Type: image/jpeg' \
    --data '@/C:/Rest of path to locally saved Picture.jpeg'
    

    Finally, the image has been uploaded to the needed folder as intended:

    For my specific use case, I wanted to replace this activity, as I wanted to upload the files needed in ML training directly using a 3rd party REST API and not wanting to involve orchestrator just to call 1 activity.

2 Likes