Parsing XML return from RESTAPI GET

BruceFerjulian
Tera Contributor

I am a NOOB with the RESTAPI and servicenow.

 

I make a request using the following RESTAPI curl ( GET )

 

 

GET https://ourcompany.service-now.com/api/now/table/alm_hardware?sysparm_query=serial_number%3D10QXHV2&sysparm_display_value=all&sysparm_exclude_reference_link=false&sysparm_suppress_pagination_header=true&sysparm_fields=ci&sysparm_limit=1&sysparm_query_no_domain=true 

 

In the return I get the following for ( ci ) field.

 

<?xml version="1.0"?>
<response>
  <result>
    <ci>
      <display_value>IEOFLN50</display_value>
      <link>https://ourcompany.service-now.com/api/now/table/cmdb_ci/66fbc8851bc877c8376c62007e4bcb28</link>
      <value>66fbc8851bc877c8376c62007e4bcb28</value>
    </ci>
  </result>
</response>

 

 

If I navigate ( separately ) using a web browser to the https link one of the data points I am looking for is at the link. The following is a small number of items the were returned in the curl to get the url link.

 

<?xml version="1.0" encoding="UTF-8"?>
<response>
  <result>
    <u_os_type>LINUX</u_os_type>
    <u_remote_mgmt_ip_link>10.236.230.101</u_remote_mgmt_ip_link>
    <ip_address>10.236.230.102</ip_address>
  </result>
</response>

 

Is there a way in the initial curl ( GET ) request for add some field that will expand these linked to url's and expand the data instead of having to cache the links away and then do subsequent curl requests for the data and then add it to the initial results.

 

In short am I missing something in my ( GET ) request that is not expanding all the data before it's returned?

 

 

 

1 ACCEPTED SOLUTION

Claude DAmico
Kilo Sage

You can use the sysparm_fields parameter to specify exactly which fields you want returned from records including dot-walking to reference field values. In this case, adding "ci.u_os_type,ci.u_remote_mgmt_ip_link,ci.ip_address"  to your list of fields should get that for you.

Claude E. D'Amico, III - CSA

View solution in original post

2 REPLIES 2

Claude DAmico
Kilo Sage

You can use the sysparm_fields parameter to specify exactly which fields you want returned from records including dot-walking to reference field values. In this case, adding "ci.u_os_type,ci.u_remote_mgmt_ip_link,ci.ip_address"  to your list of fields should get that for you.

Claude E. D'Amico, III - CSA

Perfect. I was hoping one flag that just expanded instead of my new learned term ( .dot walking ). Still getting all the data in one request when calling it correctly works. Thanks again.