How to remove user's access to a project using Web Services API
search cancel

How to remove user's access to a project using Web Services API

book

Article ID: 57514

calendar_today

Updated On:

Products

Rally On-Premise Rally SaaS

Issue/Introduction

How to remove user's access to a project using Web Services API?

Resolution

In Web Services API object model there is a UserPermission object? with a User attribute which can be used in queries:

In this example we query by user reference: user/<USER_OID>.
Here is a URL query equivalent of the query in the WS API interactive document:

https://rally1.rallydev.com/slm/webservice/v2.0/projectpermission?query=(User = /user/<USER_OID>)

In order to delete a specific project permission of a specific user we need to get the unique ObjectID of this permission, hence the query above.
The screenshot above shows a note that Project attribute of ProjectPermission object cannot be used in queries.
This query will not work:

https://rally1.rallydev.com/slm/webservice/v2.0/projectpermission?query=((User = /user/<USER_OID>)AND (Project = /project/<PROJECT_OID>))

and will return error:

{
QueryResult: {
Errors: [
"Could not parse: Attribute "Project" on type ProjectPermission is not allowed in query expressions."
],
Warnings: [ ],
TotalResultCount: 0,
Results: [ ]
}}


In this example we delete it using a curl command. A browser REST client can also be used with the exact same endpoint.

curl --header "zsessionid:<API Key - include the underscore before the key>" -H "Content-Type: application/json" -X DELETE https://rally1.rallydev.com/slm/webservice/v2.0/projectpermission/<OBJECT_OID>

This example is using API Key for authentiacation ("zsessionid:<API Key - include the underscore before the key>" ) will work only in on-demand SaaS CA Agile Central. In on-premises environment a basic authentication method (-u '<User>@<Company.com>:<PASSWORD>' ) can be used.


If the curl command to delete the projectpermission is successful the result returned in the terminal does not contain any errors, but there is no explicit confirmation that the projectpermission was deleted:
{"OperationResult": {"_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": [], "Warnings": []}}

To confirm that it was indeed deleted, reload the same query
https://rally1.rallydev.com/slm/webservice/v2.0/projectpermission?query=(User = /user/<USER_OID>)

The success can be verified by an administrator in the UI, on the user's details page, on the Setup tab.