Deleting Multiple Objects via REST API #7477
-
Good afternoon. Is it possible to delete multiple objects not through a method that requires a unique ID? curl -s -X DELETE -H "Authorization: Token $TOKEN" -H "Content-Type: application/json" https://yourdomain.com/api/virtualization/virtual-machines/?cluster=4 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Bulk deletion via the REST API requires a unique ID to protect against race conditions, wherein the attributes of some objects are modified immediately prior to the deletion request. This approach ensures that only the explicitly identified objects will be deleted. |
Beta Was this translation helpful? Give feedback.
-
What are the workarounds for solving this case?
But nothing happened, although the temp.json file contains the "id" of the field. |
Beta Was this translation helpful? Give feedback.
-
If you really want to do this, you probably need to transform the JSON data with a tool like
Then use the transformed data as the input to your bulk delete, rather than the original output. |
Beta Was this translation helpful? Give feedback.
If you really want to do this, you probably need to transform the JSON data with a tool like
jq
. For example:Then use the transformed data as the input to your bulk delete, rather than the original output.