Use REST API to get details of a Change Request

Shikhar Tandon
Kilo Contributor

Hi,

I am very new to this SNOW.

I am looking for help in REST API solution where I can pass the Change Request Number and in the output response I can get the Change request values like "Type", "Configuration Item", "Short description", "description".

Something like - https://test.service-now.com/api/sn_chg_rest/change/standard/CHG1234567

some this kind of URL and in response the values of these fields from the CRQ - "Type", "Configuration Item", "Short description", "description".

Looking forward for some help.

Thanks

1 ACCEPTED SOLUTION

Hi @Shikhar Tandon ,

CI is also coming in correct format. This is how ServiceNow provides results for any reference field. If you are expecting Display value of CI, then make sysparm_display_value as true.

Then, your response would look like -

{
  "result": {
    "short_description": "testing else part",
    "cmdb_ci": {
      "link": "https://instance.service-now.com/api/now/table/cmdb_ci/f383a25ddb80d890bcb8dd3b5e96197a",
      "display_value": "HelloCI"
    },
    "description": "Datachange  Request"
  }
}

Let me know if issue persists.

Mark this as Correct answer and close this thread for reference to other people seeking same info.

Regards,

Shubham

 

View solution in original post

18 REPLIES 18

Hi @Wojtek Winnicki 

Thanks for the reply. I will test and let you know!

Thanks

Hi @Wojtek Winnicki 

This is working good, but if I want only specific fields can I modify this URL? and how?

Thanks 

 

Hello @Shikhar Tandon 

add to url "&sysparm_fields=" and after equal sign list of the fields that you want to get. Example "&sysparm_fields=description%2Ccmdb_ci%2Cstate%2Ctype". 

ShubhamGarg
Kilo Sage

Hi @Shikhar Tandon ,

You can use ServiceNow Out-of-box Table API to retrieve the results you are expecting in your problem statement.

Go to Rest API Explorer.

Namespace - now

API name - Table API

Retrieve a record

GET https://instance-name.service-now.com/api/now/table/{tableName}/{sys_id}

Fill the path parameters tableName & sys_id.
Filter the results basis on Query Parameters. E.g. sysparm_fields to get only desired fileds data.

Let me know if issue persists.

Mark this as Correct/Helpful if applicable.

Regards,

Shubham

Hi @Shubham Garg 

Thanks for the reply.

I already tried these steps.

In the table name i passed - Change Request and in the sys id the sys id. the results I was getting was not having fields i require like Type", "Configuration Item", "Short description", "description".

Whereas I did not try the Query parameter field as I do not know what exactly will go there.

Can you please suggest further.

Thanks!