How to update Per Robot Credentials in Classic Folders via API

Hello Cosmin_Mandoc

Did you figure it out? How to update one asset without removing others?
From my experience - it works on Modern Folders when you have PerUser Credentials. But on the classic folder where you have PerRobot Credentials it removes everything and updates only one.

Hi @mac.witos,

I inspected what is occurring with the Network traffic when making the request from the Orchestrator Web UI (2020.10) and I did not experience the inability to update a single Per Robot Value as you and the other topic describe it.

Please see the following payloads in the POST and PUT request to /odata/Assets followed by a diff between the two.

Initial Creation with POST

{
	"ValueType": "Credential",
	"CredentialUsername": "",
	"Name": "Test_PerRobot",
	"Description": null,
	"ValueScope": "PerRobot",
	"HasDefaultValue": false,
	"RobotValues": [{
		"RobotId": 1,
		"RobotName": "Robot 03",
		"Id": -9007199254740988,
		"ValueType": "Credential",
		"CredentialUsername": "03",
		"CredentialPassword": "0303",
		"CredentialStoreId": 1
	}, {
		"RobotId": 2,
		"RobotName": "Robot 02",
		"Id": -9007199254740989,
		"ValueType": "Credential",
		"CredentialUsername": "02",
		"CredentialPassword": "0202",
		"CredentialStoreId": 1
	}, {
		"RobotId": 3,
		"RobotName": "Robot 03",
		"Id": -9007199254740990,
		"ValueType": "Credential",
		"CredentialUsername": "01",
		"CredentialPassword": "0101",
		"CredentialStoreId": 1
	}]
}

Update Asset with PUT

{
	"Id": 1,
	"ValueType": "Credential",
	"CredentialUsername": "",
	"Name": "Test_PerRobot",
	"Description": null,
	"ValueScope": "PerRobot",
	"HasDefaultValue": false,
	"CanBeDeleted": true,
	"RobotValues": [{
		"RobotId": 1,
		"RobotName": "Robot 03",
		"Id": 3,
		"ValueType": "Credential",
		"CredentialUsername": "03",
		"CredentialPassword": "030303",
		"CredentialStoreId": 1
	}, {
		"RobotId": 2,
		"RobotName": "Robot 02",
		"Id": 2,
		"StringValue": "",
		"BoolValue": false,
		"IntValue": 0,
		"ValueType": "Credential",
		"Value": "username: 02",
		"CredentialUsername": "02",
		"CredentialPassword": "",
		"ExternalName": null,
		"CredentialStoreId": 1
	}, {
		"RobotId": 3,
		"RobotName": "Robot 03",
		"Id": 1,
		"StringValue": "",
		"BoolValue": false,
		"IntValue": 0,
		"ValueType": "Credential",
		"Value": "username: 01",
		"CredentialUsername": "01",
		"CredentialPassword": "",
		"ExternalName": null,
		"CredentialStoreId": 1
	}]
}

Left is the POST request, with PUT request on the Right
You’ll notice a few differences in the payloads and I’m sure many of the extra fields could be removed. But notably the inclusion of the Value with an empty CredentialPassword is likely how it determines if the the PerRobot Credential Value should be updated.

In my test, I only updated the credential of Robot 03

Running 3 Jobs after the PUT Request was processed, I can verify the Robot 01 and Robot 02 was not updated and still provide the original credentials

image

image

image

When in doubt, I always find it easiest to inspect the traffic while using the Web UI to get a feel for what requests are being made and in what order when the Swagger Documentation is not clear enough.