Maintaining Relations with the REST API
The REST API of the 4me service has been extended to make it possible for developers to maintain the one-to-many as well as the many-to-many links between records.
Since it has recently become possible to link multiple CIs to a request, we can use that feature to provide some examples.
The following cURL call can be used to add a configuration item to a request:
curl -u "token:x" -X POST "https://api.4me.com/v1/requests/123456/cis/654321"
And here’s how the API can be used to remove that same CI again:
curl -u "token:x" -X DELETE "https://api.4me.com/v1/requests/123456/cis/654321"
Removing all CIs from the request is even simpler:
curl -u "token:x" -X DELETE "https://api.4me.com/v1/requests/123456/cis"
In the above examples, token
represents a user’s 4me API token. You can find your API token in the “Personal Information” section of the Settings console.
Take a look at the Change Log of the 4me Developer documentation to look at all the possibilities that have been added.