Why is state value not persisting with RESt API sn_chg_rest/change/standard request

Todd O
Tera Guru

I'm using out of the box REST API explorer to simply update a Standard Change record's "state" value from "New (-5)" to "Scheduled (-2)." When I submit the request I get a successful 200 OK response but the change does not happen on the CR. It's like it ignores it.  I've tried all the following approaches and none of them work. Any suggestions would be very much appreciated.

  1. I'm using this method: PATCH /sn_chg_rest/change/standard/{sys_id}
  2. I verified that my Standard change template does not have "state" as read-only. Here is the list of read-only fields when I run StdChangeUtils().getReadOnlyFields() method: "description,backout_plan,short_description,implementation_plan,test_plan,justification,category,business_service,parent"
  3. When specifying the parameter "state" in the payload, I've tried it as both a query parameter as well as JSON using the body. Neither work. There is a HI KB post that describes that you must use the Label (Scheduled) thus the reason I've tried both "Scheduled" as well as the -2 and "-2" values which is the value for Scheduled. Neither work - fact using the numbers gives an error just as the HI KB post discusses. 
  4. I've ensured that I also called the POST /conflict method as well to prove there is NO scheduling conflict with the CI. That doesn't solve it. 
  5. I've ensured that all required fields are populated with data values before attempting to change the state. That doesn't solve it either. 
  6. I've reviewed the business rules, workflows and Flow Designer objects to look for any running processes that would abort the attempted update and found nothing. 
  7. I've tried updating a different field (e.g., assigned_to and that works). But "state" does not work.

Finally, please see the images below showing the attempt and then results. Again, the question is why is it the state value does not get updated with this REST API call?

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Hi,

Did you check is there any dictionary override for state field on change_request table for read-only which is blocking the update from API?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

Michael Fry1
Kilo Patron

Looks like you're just querying for the record, not setting any values. Under Request Body, do you have state, -2 set?

 

find_real_file.png

Hi @Michael Fry yes, per my original post (#3) I've tried it using both the request body (as you suggest) as well as the query parameters. If you read the SN documentation, it indicates you can use either - thus reason why I've tried both.  In fact, SN docs say that Query params will override the request body - but again either of them are supposed to work. I'm still hoping I get some more input on some things I haven't tried. Thanks.

Todd O
Tera Guru

Here are a few more tidbits about my scenario.

  1. If I try this same scenario in my PDI, it works as expected. Therefore, there must be some behavior in our QA instance that is aborting the update for some reason.
  2. I've reviewed BRs and logs and cannot find any indication as to why this update request is being rejected. 
  3. As a reminder, I've already tried the request using the request body vs query parameters. Neither scenario is working as expected. 

Thanks in advance.

Hi,

Did you check is there any dictionary override for state field on change_request table for read-only which is blocking the update from API?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader