How to set [value per robot] value via API call?

orchestrator
assets
api

#1

I need to update the asset value (per robot) before starting a job. Is there any way to set it with an API call?
According to API AssetRobotValueDto does not support any method.


#2

Here’s some python code that does just that (using the requests library).

assets_api = "https://demo.uipath.com/odata/Assets(ASSET_ID_HERE)"

robot_values = [
    {
        "RobotId" : robot_id1,
        "RobotName" : robot_name1,
        "StringValue" : new_asset_value1,
        "ValueType" : "Text"
    },
    {
        "RobotId" : robot_id2,
        "RobotName" : robot_name2,
        "StringValue" : new_asset_value2,
        "ValueType" : "Text"
    }
]
asset_value = {
    "Id" : asset_id,
    "Name" : asset_name,
    "Value" : "[Value per robot]",
    "ValueType" : "Text",
    "ValueScope" : "PerRobot",
    "CanBeDeleted" : 'true',
    "StringValue" : 'null',
    "BoolValue" : 'false',
    "IntValue" : 0,
    "CredentialUsername" : 'null',
    "CredentialPassword" : 'null',
    "RobotValues" : robot_values
}
response = requests.put(assets_api, headers=header_auth, json=asset_value)

#3

Hello, I am now using the postman to call

https://staging.uipath.com/odata/Assets(427) and below is my body. However, have no idea why the return status = 400 empty or invalid anti forgery header token? can anyone help what is the problem?

{
“Id”: 427,
“Name”: “strRequest”,
“CanBeDeleted”: true,
“ValueScope”: “PerRobot”,
“ValueType”: “Text”,
“Value”: “[Value per robot]”,
“StringValue”: null,
“BoolValue”: false,
“IntValue”: 0,
“CredentialUsername”: null,
“CredentialPassword”: null,
“RobotValues”: [
{
“RobotId”: 955,
“RobotName”: “chatbot”,
“StringValue”: “aaa”,
“ValueType” : “Text”,
“Id”: 427
}

]
}


#4

Is it possible to update the password of only 1 robot using this method if there are other robot credentials configured for that same asset? I just read another post that says when he changes the password of 1 robot, it deletes the other configured robot credentials.