Task 3 - Assign the Product
In this task, you assign a seat from the product pool to the user.
By the end of this task you will be able to:
- Create a direct product assignment for a user.
- Tell a new assignment from one that already existed.
You will use the following operation in this task:
| Operation | HTTP request |
|---|---|
| Assign Product | POST /teams/{team-id}/assignments |
Step 1 - Assign the product
You need the user ID from Task 1 and the product ID from Task 2.
Warning: This request assigns a seat to a real user.
In Postman, run the Create direct team assignment request.
The request
Postman sends this request with the collection’s authorization adding your access token. The following cURL command shows the structure of the request. You don’t need to run it.
curl -X POST \
'https://developer.api.autodesk.com/team-admin/v1/teams/<YOUR_TEAM_ID>/assignments' \
-H 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{"userId":"<YOUR_USER_ID>","productId":"<YOUR_PRODUCT_ID>"}'
You must supply userId and productId. The assignmentType field is optional. If you include it, set it to DIRECT. You can create direct assignments only.
Response
A new assignment returns a 201 status code with the assignment in the response body:
{
"userId": "US1234567890",
"email": "ada.lovelace@example.com",
"teamId": "100001",
"productId": "prod_8f3a1c9d7b2e",
"productName": "Example Product Premium",
"assignmentType": "DIRECT"
}
The response also includes a Location header that contains the path of the new assignment.
Step 2 - Understand the outcomes
The operation is safe to repeat. If the assignment already exists, the API changes nothing and returns a 200 status code with the current assignment. In both cases, the response body is the current assignment.
A request can also be rejected:
- A
422status code means the request was well formed but couldn’t be applied to your team. For example, the pool might have no free seats, or the product might be one that the API doesn’t support for assignments. - A
404status code means a resource in your request wasn’t found. Check the team, user, and product IDs.
For the full list of status codes, see Error Handling.
See also
- Continue with Task 4 - Verify and Remove an Assignment.