Quantcast
Channel: VMware Communities : All Content - vRealize Operations Manager
Viewing all articles
Browse latest Browse all 5485

REST API assignRolePermissionToUserGroup

$
0
0

Im attempting to update the objects our customers have rights to in vROps, programmatically through the REST API. The idea is that when a customer spins up or destroys a VM through vRA, we would go find all their provisioned VMs and rebuild the objects list for their vROps group through vRO using the vROps REST API. I have a vRO workflow that looks like this:

 

var groupId = "8c380090-d5c3-42a7-a77c-5de4437ce85b"
var resourceId = "8e62002f-0965-47e2-a82a-6d403b44b756"

var body = {"traversal-spec-instances" : [{
  "traversal-spec-instance" : {       "selectAllResources" : false,       "name" : "vSphere Hosts and Clusters",       "resourceKind" : "vSphere World",       "adapterKind" : "VMWARE",       "resourceSelection" : [{            "resourceId" : [                 resourceId,                 "4abb32e5-1fd0-443b-85ed-4995da4a1a0d"            ],            "type" : "SPECIFIC"       }]  }
}],
"allowAllObjects" : false,
"roleName" : "ReadOnly"
}
System.log(JSON.stringify(body));


var request = restHost.createRequest("PUT", "/auth/usergroups/" + groupId + "/permissions", body);
request.contentType = "application/json";


var json = JSON.stringify(System.getModule("com.vmware.library.http-rest").xml2json(request.execute().contentAsString));
System.log(json);


 

This produces the JSON string:

{"traversal-spec-instances":[{"traversal-spec-instance":{"selectAllResources":false,"name":"vSphere Hosts and Clusters","resourceKind":"vSphere World","adapterKind":"VMWARE","resourceSelection":[{"resourceId":["8e62002f-0965-47e2-a82a-6d403b44b756","4abb32e5-1fd0-443b-85ed-4995da4a1a0d"],"type":"SPECIFIC"}]}}],"allowAllObjects":false,"roleName":"ReadOnly"}

 

There are no examples of the request body so i'm just doing what i am interpreting the REST API documentation requires.

 

Executing this results in the error:

{"error":{"message":"Invalid input format.","xmlns:ops":"http://webservice.vmware.com/vRealizeOpsMgr/1.0/","moreInformation":{"info":{"content":"/suite-api/api/auth/usergroups/8c380090-d5c3-42a7-a77c-5de4437ce85b/permissions","name":"api-uri"}},"httpStatusCode":400,"xmlns:xs":"http://www.w3.org/2001/XMLSchema","xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","apiErrorCode":400}}

Which isn't very helpful.

 

I've verified through other API calls that the groupId is correct and returns a valid grump object through the REST API. So my assumption at this point is that the body of the request is malformed but im not sure how and the errors aren't giving me much to go on.


Viewing all articles
Browse latest Browse all 5485

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>