DELETE-ing Objects with the API
Migration Notes from 0.5 API
- In Buzz 0.5 the unique ID of the object to be updated could be included in the body of the request or in the path. In the 2.0 API the ID must be in the path.
Deletes use the http DELETE
method. In order to delete an object you must pass the unique id
of that object in the request path.
Note, that many objects have extensive validation to prevent data inconsistencies and it may not always be possible to delete an object. Generally, to delete something in Buzz you need to be assured that no other object is dependent on the object to be deleted. For example, Buzz will not allow you to delete an Advertiser
, if a Campaign
belongs to that Advertiser.
Basic DELETE Syntax
curl -X DELETE "[host]/rest/[resource]/123" -b cookies.txt -H "Content-Type: application/json"
If a DELETE is not allowed the API will return an http 405 error and a message like the one below:
{"detail":"Method \"DELETE\" not allowed."}
Bulk DELETE
For certain objects, you can delete multiple objects in a single DELETE by using the dedicated /bulk
resources corresponding to the object you wish to update. For example, to delete multiple Roles in a single transaction, you can DELETE to /roles/bulk.
To bulk DELETE, specify the IDs for all target objects in the URL path as shown below:
curl -X DELETE "[host]/rest/[resource]/bulk?ids=1,2" -b cookies.txt
On a successful bulk DELETE the API will respond with a list of all the objects deleted. If any errors are encountered the entire operation will fail and the response will provide feedback.
Updated almost 4 years ago