Is it possible to change sys_class_name via REST API?

dcherian
Giga Expert

Hi,

 

I have a system which only uses REST API to push data to ServiceNow. When the classification changes for a device (for example an OT device now is discovered to be a OT sensor), how should I update the record? PUT gives me a 404 if I try to PUT against the new table name with the same sys_id. 

 

Is there a way to achieve the above without resorting to a DELETE and POST (create a new record in the new table)?

 

thanks,

Deepak

1 ACCEPTED SOLUTION

I am checking the class with the "sys_class_name" attribute in the response as well. I just found out from another serviceNow expert that the {tableName} param should be target the highest common class between the input class and the replacement class in order to avoid the 404 error.

 

In my case, I was trying to move from "cmdb_ci_pc_hardware" to "cmdb_ci_server" - so when I set the {tableName} to "cmdb_ci_hardware", it worked!

 

Thanks for the pointers @RaghavSh . I am marking this as the solution

View solution in original post

9 REPLIES 9

RaghavSh
Kilo Patron

You dont need to put the sys_id as that is automatically generated, did you try to change the class name alone?

I dont think, servicenow will allow you to put sys_id explicitly.


Raghav
MVP 2023

I am using the REST API:

Table API

 
Allows you to perform create, read, update and delete (CRUD) operations on existing tables

Modify a record
PUT https://<instance-url>/api/now/table/{tableName}/{sys_id}

It allows me to change the other attributes in the record, but not the sys_class_name

using same REST API explorer, I was just able to change the class from "cmdb_ci_computer" to "cmdb_ci_win_server" :

 

Screenshot 2022-12-08 at 1.42.31 PM.png

If you are using the correct request body check if there are some data policies or ACLs restricting the same, I did it in OOB instance.


Raghav
MVP 2023

@dcherian did you try this in OOB instance?


Raghav
MVP 2023