Create Standard change through REST API?

ryancurrah
Kilo Contributor

Is it possible to create a Standard change through the REST API? If so can you post an example or point to a reference?

19 REPLIES 19

Hi Martin,


Interesting question!



There is a sample curl command mentioned in the docs


https://docs.servicenow.com/bundle/istanbul-servicenow-platform/page/integrate/inbound-rest/referenc...



curl "https://instance.service-now.com/api/sn_sc/servicecatalog/items/3f1dd0320a0a0b99000a53f7604a2ef9/sub..." \
--request POST \
--header "Accept:application/json"\
--header "Content-Type:application/json" \
--data "{'variables':{'urgency':'2','comments':'This is sample incident'}}" \
--user 'admin':'admin'


{
"result": {
"record": "api/now/table/incident/1584f89767211200f579794717415a79,
"
redirect_url": "incident.do?sys_id=1584f89767211200f579794717415a79&sysparm_view=ess"
}
}



I just tried a curl command towards the OOB record producer "Emergency Change" - without specifying the CI -   which perhaps explains why the sys_parm_view is empty.


So half "pulled off" from my side



curl "https://instance_name.service-now.com/api/sn_sc/servicecatalog/items/389d27110a0a0b27004f344ed8a38ee..."  


--request POST  


--header "Accept:application/json" --header "Content-Type:application/json"


--data "{'variables':{'short_description':'short des'}}"  


--user 'admin':'admin'



{


"result":{


"record":"api/now/table/change_request/a96b680913950700125ad8228144b0b7",


"redirect_url":"change_request.do?sys_id=a96b680913950700125ad8228144b0b7&sysparm_view="


}


}



Used the REST API Explorer to create Standard Change via the POST Record Producer method:



REST API 1.png



REST API response.pngI


It created the change, and gave a redirect to the change record created.



See below screenshot of the resultant change:



Resultant Change.png



And then, just like when working via the GUI, you would then use the Table API to update the resultant change record with the "non template" data required by the change.


@Marting: Thank you for detailing the steps here. It looks like we would need two steps to create a change using standard change template, 1- Use the ServiceCatalog API to create the standard change & 2- Use the Table API to update the non template data required for that change. 

My question: Is it possible to override the template data while making the API call to ServiceCatalog API so that the second call to the Table API can be avoided?

In our case, we would still want to utilize the capabilities of the standard change template via ServiceCatalog API, but would want the capability to override the template data. 

Any suggestions or directions are appreciated!

@Marting: Thank you for detailing the steps here. It looks like we would need two steps to create a change using standard change template, 1- Use the ServiceCatalog API to create the standard change & 2- Use the Table API to update the non template data required for that change. 

My question: Is it possible to override the template data while making the API call to ServiceCatalog API so that the second call to the Table API can be avoided?

In our case, we would still want to utilize the capabilities of the standard change template via ServiceCatalog API, but would want the capability to override the template data. 

Any suggestions or directions are appreciated!

HI Rahul,

I don't believe you can override the template data without a second call.

But you may find you cannot event override it with a second call.

The while point about a standard change is that it is "standard". And when setting the standard change template up, you specify what fields are not be changed.

I haven't tested whether you can update these fields via REST call or not.

I guess the question is one of how the UI is locking the template fields. Client Script, UI Policy or Data Policy.

If the latter, then the REST api would also fail to update the template fields.

I will need to peek under the covers and see how template fields on a standard change get locked.