Arron_Golaup | 2022-05-23 15:43:26 UTC | #1
Hello, I am attempting to update an existing custom role via Genesys Cloud API. Objective is to add the new troubleshooting permissions for auto agent logging.
Unfortunately each time I run the script it deletes all permissions on the targeted role, when logged into the Org and looking at the role it shows an error saying 'your default role is out of date' although I have clearly added the value "default": false.
To point out the obvious, yes the change is only one radio button but i need to do this on multiple customer Orgs and would rather automate. Any help would be appreciated !
Please see my script below (removed the ID of the role).
Using PATCH /api/v2/authorization/roles/{roleId}
let apiInstance = new platformClient.AuthorizationApi(); let roleId = ""; // Id of the role let body = { "roleNeedsUpdate": true, "permissionPolicies": [ { "domain": "troubleshooting", "entityName": "", "actionSet": [ "" ], "allowConditions": false } ], "default": false, "base": false }; apiInstance.patchAuthorizationRole(roleId, body) .then(function(rolesObject){ console.log(rolesObject); console.log("Role updated"); }) .catch((err) => { console.log("There was a failure updating the role"); console.error(err); });
charlie.conneely | 2022-05-26 11:12:26 UTC | #2
Hi Arron
This looks like a bug. We're opening a ticket now to resolve the problem.
As a temporary fix, you could use the GET and PUT endpoints together to update the role. I've attached an example below.
apiInstance.getAuthorizationRole(roleId, opts)
.then((data) => {
console.log("Data returned from GET: " + JSON.stringify(data, null, 2));
data.permissionPolicies[data.permissionPolicies.length] = {
"domain": "troubleshooting",
"entityName": "logCapture",
"actionSet": [
"*"
],
"allowConditions": false
}
apiInstance.putAuthorizationRole(roleId, data)
.then(function(rolesObject){
console.log("Data returned from PUT: " + JSON.stringify(rolesObject, null, 2));
console.log("Role updated");
})
.catch((err) => {
console.log("There was a failure updating the role");
console.error(err);
});
})
.catch((err) => {
console.error(err);
});
Thanks for reporting, Charlie
system | 2022-06-26 11:12:40 UTC | #3
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 14844