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 @Shikhar Tandon ,

In the query parameter > sysparm_fields, put comma separated fields (column name not label) which you are expecting in result. It will work.

Attaching screenshot for reference.

 

Let me know if issue persists.

Mark this as Correct/Helpful if applicable.

Regards,

Shubham

Hi @Shubham Garg 

I tried the approach you mentioned.

I fetched the data for 3 parameters - short description, description and configuration item.

I filled the sysparm_fields checkbox, I clicked on the pencil icon beside it and selected the three required fields as visible in second ss

find_real_file.png

find_real_file.png

 

but int the result body description and short description fields are correct but the configuration item is coming in weird form.

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

please suggest.

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

 

Hello @Shikhar Tandon ,

Just wanted to follow-up whether your issues is resolved or you require further assistance on your problem statement.

If yes, let me know. Else, feel free to mark this answer as correct so that others can use it as correct reference.

Regards,

Shubham

Hi @Shubham Garg 

Thankyou for sharing the knowledge. I had one more small doubt if you could help.

Can I some way take out the sys_id using API which is to be used when calling this above mentioned API.

Can you let me know if by change number we can take out the sys_id?

Thanks