- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2018 04:40 AM
Hi, all
I'm trying to add multiple comments one by one using Table API:
/api/now/table/incident/{incident_id}
body: {"comments":"single comment"}
The problem is that all the comments are added for admin user. If there is a way to specify a user for incident comment?
Thank you, regards, Halyna
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2018 02:17 AM
Comments are added as the user that connects via the REST API. I you use "admin" for each REST API call, it will always be "admin". If possible you should use the correct user. As an alternative, you can add the user to the comment text, but it will still show "admin" as the user who added the comment.
Since you are using the direct table API, there is no intermediate transformation step where you would be able to handle this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2018 05:32 AM
Hi Halyna,
I don't think so that is possible. But that needs to be explored.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2018 01:02 AM
Thank you for replying
So it's possible to save comment only for user witch is authorized in a system?
Regards, Halyna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2018 02:10 AM
Hi Halyna,
When you call table API, you need to let specific user authorized.
Comments are added for the user.
If you want to add comments for user "rest.test", you can write as follows.
--------------------------------------------
# sample in Python from REST API Reference
username = "rest.test"
password = "pass"
rest_endpoint = "[yourinstance]/api/now/table/incident/[sys_id]";
headers = {"Content-Type":"application/xml","Accept":"application/xml"}
# PUT
r = requests.put(
rest_endpoint,
auth=(username, password), # let username authorized
headers=headers,
data="<request><entry><comments>Single comment</comments></entry></request>"
)
print(r.status_code)
--------------------------------------------
"auth=(username, password)" adds username and password to http header.
The result is as follows.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2018 02:17 AM
Comments are added as the user that connects via the REST API. I you use "admin" for each REST API call, it will always be "admin". If possible you should use the correct user. As an alternative, you can add the user to the comment text, but it will still show "admin" as the user who added the comment.
Since you are using the direct table API, there is no intermediate transformation step where you would be able to handle this.