POST /v1/spaces/:space_id/user_roles
HTTP Verb: POST
Available statuses: 201 Created, 404 Not Found, 422 Unprocessable Entity
Object: UserRole
Location: available
Formats: XML, JSON
Create a user role (invite a user to space).
Params
To invite a user to space, a data body must be provided. Data can be provided in three formats: XML, JSON and query string. To specify data type of XML or JSON add the Content-type: application/(json|xml) header to request headers, if you want to provide query string simply skip the Content-type header.
All params should be sent in the user_role namespace, e.g.:
XML
<user_role>
<user_id>_user_id</user_id>
<role>member</role>
...
</user_role>
JSON
{"user_role":{"user_id":"_user_id","role":"member"...}}
Query string
user_role[user_id]=_user_id&user_role[role]=member...
Check the full list of available params on user role object fields reference
Examples
Request XML, using cURL utility:
curl -i -H "Authorization: Bearer _token" -d "user_role[user_id]=aIJbLeNzir4jAWadbNA33N" -d "user_role[role]=member" https://api.assembla.com/v1/spaces/_space_id/user_roles.xml
Response:
HTTP/1.1 201 Created
Server: nginx/0.8.55
Date: Mon, 10 Sep 2012 12:29:36 GMT
Content-Type: application/xml; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 201
Location: https://api.assembla.com/v1/spaces/test-1/user_roles/439
...
<?xml version="1.0" encoding="UTF-8"?>
<user-role>
<status type="integer">1</status>
<invited-time type="datetime">2012-09-10T12:29:33Z</invited-time>
<invited-by-id>bgnP_qA1Gr2QjIaaaHk9wZ</invited-by-id>
<space-id>b89TL8MYWr4id7adbNA33N</space-id>
<agreed-time nil="true"></agreed-time>
<user-id>aIJbLeNzir4jAWadbNA33N</user-id>
<role>member</role>
<id type="integer">439</id>
<title nil="true"></title>
</user-role>
Request JSON, using cURL utility:
curl -i -H "Authorization: Bearer _token" -d "user_role[user_id]=aIJbLeNzir4jAWadbNA33N" -d "user_role[role]=member" https://api.assembla.com/v1/spaces/_space_id/user_roles.json
Response:
HTTP/1.1 201 Created
Server: nginx/0.8.55
Date: Mon, 10 Sep 2012 12:27:38 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 201
Location: https://api.assembla.com/v1/spaces/test-1/user_roles/438
...
{
"status":1,
"invited_time":"2012-09-10T12:27:35Z",
"invited_by_id":"bgnP_qA1Gr2QjIaaaHk9wZ",
"space_id":"b89TL8MYWr4id7adbNA33N",
"agreed_time":null,
"user_id":"aIJbLeNzir4jAWadbNA33N",
"role":"member",
"id":438,
"title":null
}
JSON is formatted here for readability, in a real response JSON body is inline with no indentation.
Note: pay attention to Location header, this is the URL where newly created resource is located, you can GET on this URL to access this resource.
Description for each field: user role object fields reference