Can you help me creating comments in issues using the REST API?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2023 06:17 AM
Hi, I'm trying to create issue comments using API but with no success.
I'm using the following endpoint:
https://dev186246.service-now.com/api/now/v1/table/incident/a83820b58f723300e7e16c7827bdeed2
to get information about an issue I created myself in a Service Now developer instance user interface but I can't see the commnents I created in that same issue using the Service Now developer instance user interface.
The idea was to know the comments field name in order to use it in the update issue endpoint to create new comments using the REST API issue update endpoint:
https://instance.service-now.com/api/now/v1/table/incident/{sys_id}?sysparm_exclude_ref_link=true
Can you please help?
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2023 11:11 PM
Hi @ALTICERPA
You need to make a POST call to create a new incident. Please refer to below code snippet.
var requestBody = "{\"short_description\":\"test incident\",\"comments_and_work_notes\":\"Test Comment\"}";
var client=new XMLHttpRequest();
client.open("post","https://<your instance>.service-now.com/api/now/table/incident");
client.setRequestHeader('Accept','application/json');
client.setRequestHeader('Content-Type','application/json');
//Eg. UserName="admin", Password="admin" for this code sample.
client.setRequestHeader('Authorization', 'Basic '+btoa('admin'+':'+'admin'));
client.onreadystatechange = function() {
if(this.readyState == this.DONE) {
document.getElementById("response").innerHTML=this.status + this.response;
}
};
client.send(requestBody);
For adding comments and worknotes during creation of an incident, you can pass value to "comments_and_work_notes" field. Also, if you want to update existing incident record with new comments, you can make use of a PUT REST API call.
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2023 11:49 PM - edited ‎12-26-2023 11:50 PM
Hi
Please check below KB article?
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0860915
set sysparm_display_value=true true while making api request.
Your can make request like below:
https://dev186246.service-now.com/api/now/v1/table/incident/d632cc0a2f612110ae17debcf699b64b?sysparm...
Thanks
Anil Lande