Combining Multiple REST API Requests
In this exercise we will modify the assignment of a request. Again this requires a two-step approach: you need to retrieve the ID of the new assignee and next you can update the member_id field on the request.
To retrieve the ID of the new assignee, you will filter on the Name. This field has a space between the first and last name. Be ware that you cannot use all characters in an URL: URLs can only be sent over the Internet using the ASCII character-set. Since URLs often contain characters outside the ASCII set, the URL has to be converted into a valid ASCII format. URL encoding replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits. For example spaces are replaced by %20 in HTTP requests.
Exercise:
Can you reassign request #704540, NNM agent on CMP00002 is down from Howard Tanner to Chris Ball?
By now you know that you have to extend the scope of personal access token with Read access rights to Person and Read/Update rights to Request.
Use the People API to find the ID of Chris Ball whose person record is also stored in the ‘widget’ account:
curl -X GET -i -H "Authorization: Bearer <personal-token>" -H "X-Xurrent-Account: widget" "https://api.4me-demo.com/v1/people?name=Chris%20Ball"
Then use /requests/:id to update the request in the ‘wdc’ account:
curl -X PATCH -i -H "Authorization: Bearer <personal-token>" -H "X-Xurrent-Account: wdc" -d '{"member_id":"143"}' "https://api.4me-demo.com/v1/requests/704540"
To verify the result use /requests/:id again, but this time to retrieve request #704540:
curl -X GET -i -H "Authorization: Bearer <personal-token>" -H "X-Xurrent-Account: wdc" "https://api.4me-demo.com/v1/requests/704540"