Combining Multiple REST API Requests
Integrations REST API Training REST API

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.


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-4me-Account: widget" ""

Then use /requests/:id to update the request in the ‘wdc’ account:

curl -X PATCH -i -H "Authorization: Bearer <personal-token>" -H "X-4me-Account: wdc" -d '{"member_id":"143"}' ""

To verify the result use /requests/:id again, but this time to retrieve request #70454:

curl -X GET -i -H "Authorization: Bearer <personal-token>" -H "X-4me-Account: wdc" ""

Next Topic