Error trying to add. comment to an incident from REST API
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2024 02:00 AM
Hello, I need some help. I'm trying to add a comment to an incident previously create but I get an error. Here is the relevant code snippet:
public void addComment(String ticketId, String comment) throws Exception {
String url = this.url + "/api/now/table/incident/" + ticketId;
log.info("URL:{}", url);
String comments = objectMapper.writeValueAsString(new ServiceNowCommentPayload(comment));
Request request = new Request.Builder()
.url(url)
.put(RequestBody.create(comments, MediaType.parse("application/json")))
.addHeader("Content-Type", "application/json")
.build();
The error I receive is:
java.lang.RuntimeException: Failed to add comment: {"error":{"message":"No Record found","detail":"Record doesn't exist or ACL restricts the record retrieval"},"status":"failure"}
Can somebody help, please?
I have also tried to add the authorization header with no luck either
Request request = new Request.Builder()
.url(url)
.put(RequestBody.create(comments, MediaType.parse("application/json")))
.addHeader("Content-Type", "application/json")
.header("Authorization", Credentials.basic(username, password))
.build();
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 08:05 AM
Hello ,
Please validate if the User you are using to update the data have the necessary roles for Incident and also validate the Incident exists on the system.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 01:59 AM
Thans for the prompt response. The problem what that I was supposed to pass the sys_id and not the incident_it. My bad.