How to create ProjectPermission and add TeamMemberships with Web Services API
search cancel

How to create ProjectPermission and add TeamMemberships with Web Services API

book

Article ID: 47760

calendar_today

Updated On:

Products

CA Agile Central On Premise (Rally) CA Agile Central SaaS (Rally)

Issue/Introduction

Below are examples of requests made via REST to create ProjectPermission and add TeamMemberships with WS API.


                            

Resolution

I. USING API KEY AUTHENTICATION

Note: generally this is a preferred method of authentication. It is easier to use, it does not require additional authentication with a security token, and unlike the security token, ApiKey is not session-specific (which makes it unnecessary to manually maintain a session when POST requests are made outside of a browser, e.g. with a curl command).

1. Generate ApiKey if it has not been already generated

For more details about ApiKey see:

Creating an API key

2. Create projectpermission

curl --header "zsessionid:zsessionid:<API Key - include the underscore before the key>" -H "Content-Type: application/json" -d"{\"ProjectPermission\":{\"Project\":\"/project/<PROJECT_OID>\",\"Role\":\"Viewer\",\"User\":\"/user/<USER_OID>\"}}" https://rally1.rallydev.com/slm/webservice/v2.0/projectpermission/create

II. USING BASIC AUTHENTICATION AND SECURITY TOKEN

Note: this authentication method should be used in subscriptions where ApiKey is disabled, and on Sandbox where ApiKey is not supported.

At the time of creation this user /user/<USER_OID> was given viewer permissions to one project:

 

Create project permission

1. Get a security token:

https://rally1.rallydev.com/slm/webservice/v2.0/security/authorize

Method: GET

A token is returned:

{"OperationResult": {"_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": [], "Warnings": [], "SecurityToken": "cb9473f7-....."}}

2. Create projectpermission. Notice the security token appended to the request:

https://rally1.rallydev.com/slm/webservice/v2.0/projectpermission/create?key=cb9473f7-....

Method: POST

Payload:

{"ProjectPermission":{
"Project":{"_ref":"/project/<PROJECT_OID>"},
"Role":"Viewer",
"User":{"_ref":"/user/<USER_OID>"}
}}

ContentType: application/json

Here is a screenshot from a REST client:

and a screenshot of the result:

 

Verified in UI:

Create team membership:

When both examples are demonstrated during the same session, the same security token can be used. No need to repeat step 1 from Example 1.

2. add team memberships.

Notice the security token appended to the request:

https://rally1.rallydev.com/slm/webservice/v2.0/user/<USER_OID>/teammemberships/add?key=cb9473f7-.....

Method: POST

Payload:

{ "CollectionItems":[{"_ref":"/project/<PROJECT_OID>"},{"_ref":"/project/<PROJECT_OID>"}] }

 

Verified success in UI:

Additional Information

keywords: agile central rally WSAPI web services