Is there an easy way to delete all comments associated with an object type? We have a workshop app that is being tested prior to going live, and are going to wipe all the edits beforehand, but also need to wipe all the comments (the comments are comments not objects)?
Unfortunately users have to delete their own individual comments from the Comments widget. There’s no option today to delete all comments all at once
You can delete comments for a given object via this endpoint.
Getting all comments for an object
curl \
-X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"resourceId":"<your-object-rid","pageSize":100}' \
https://<hostname>/comments/api/comments/page-v2
Deleting a comment
curl \
-X DELETE \
- H "Authorization: Bearer $TOKEN" \
https://<hostname>/comments/api/<your-object-rid>/comments/<comment-id>
I don’t know of a way to figure out which objects of a given object type have comments. You might have to brute force this by checking each object…but if you do that then you can use the above endpoints to programmatically delete all comments.
Two caveats:
- Deleting anything via a script is inherently risky. That alone could be reason enough not to attempt this method.
- I haven’t tested this with multiple users. The docs imply that (only?) users can delete their own comments, so maybe you’ll need to run this for each user who made a test comment.
3 Likes