- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2024 10:08 AM
Hello
I would like to post comments to existing Requested Items (RITM), I'm using the curl script below to post comments on a particular RITM and it's not working and throwing errors, can anyone tell me what was wrong with my curl command
CURL COMMAND:
curl -X POST "https://<INSTANCE URL>/api/now/table/sc_req_item" -H "Authorization: Basic <TOKEN>" -H 'Content-Type: application/json' -d '{\"comments\":\"STATUS IS COMPLETED, PLEASE VALIDATE\",\"requested_item\":\"RITM789124\"}'
ERROR:
{"error":{"message":"Exception while reading request","detail":"The payload is not valid JSON."},"status":"failure"}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2024 10:25 AM
@knchaitanya9 This is an example of PUT API to update comment using curl, make changes based on your need.
curl "https://<YourInstanceID>.service-now.com/api/now/table/sc_req_item/0495fdf11bfbb9507514415dee4bcb5c" \
--request PUT \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{\"comments\":\"Adding Test Comment\"}" \
--user 'USERID':'YourPassword'
Hope it will help you.
Thanks,
Harsh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2024 10:14 AM
@knchaitanya9 I think it should be PUT or PATCH method, POST used to create record .
Try with PUT or PATCH to update comment on ritm record.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2024 10:25 AM
@knchaitanya9 This is an example of PUT API to update comment using curl, make changes based on your need.
curl "https://<YourInstanceID>.service-now.com/api/now/table/sc_req_item/0495fdf11bfbb9507514415dee4bcb5c" \
--request PUT \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{\"comments\":\"Adding Test Comment\"}" \
--user 'USERID':'YourPassword'
Hope it will help you.
Thanks,
Harsh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2024 10:40 AM
Thanks for the quick response and @Harsh Vardhan
I see that after sc_req_item you have added an id, is that the sys_id of a RITM?
if yes, do you have a sample curl handy to get the sys_id of an RITM?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2024 10:48 AM
You can use REST API explorer to test it and you will get sample example also.
You can first get the RITM id using GET method, you will get sys_id of the record in payload then you can use PUT method to update the comments using sys_id.
Hope it will help you.