Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service Now add tag to incident through rest api

I am trying to add a tag to a service now incident, but I can't find any documentation for it anywhere. I have looked at the label and label_entry tables in the incident api. And I can not seem to tie an incident and a label together.

like image 832
Jonas Olesen Avatar asked Aug 22 '16 07:08

Jonas Olesen


1 Answers

In theory, it should be possible to do this by creating a record in the label_entry table, providing the sys_id of the tag, table and sys_id of the record you'd like to associate the tag with. After a quick test:

POST /api/now/table/label_entry {"label":"4f1094ff13162600973e70d66144b033","table":"incident","table_key":"0d97240e13aca600973e70d66144b03f","title":"Incident - INC0010018"}

I found that the table and table_key fields have write ACLs restricting access to users with the maint role. I don't have any info on why this is the case, but I suspect there may be a reason to avoid creating these records directly via API.

You could modify the ACLs or create a simple Scripted REST API that takes the tag, target record, and uses GlideRecord to insert the tag into the label_entry table. But I don't have any info on what side effects this may introduce.

like image 80
Josh Avatar answered Sep 21 '22 07:09

Josh