Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Get variable values from RITM using REST API

Akshaya R
Tera Contributor

Hi All,

 

I am trying to read the variable values from a requested item using REST API. I queried the table "sc_item_option_mtom" with the below context.

sc_item_option_mtom.request_item=<<sys_Id of the corresponding RITM>>

 

The output response from postman looked something like below:

{

   "result": [

                  {},

                  {},

                  {},

                  {},

                  {}

                  ]

}

 

What does this response mean? What is the mistake that am making here? I would like to capture the values of the custom variables in a request item. 

 

Thank you!

2 ACCEPTED SOLUTIONS

Hope you are using name of the variable?

SwapnaAbburi_0-1669708889339.png

 

View solution in original post

Please update "sysparm_display_value" to true in REST API Explorer. 

 

Note: Table level API is ok if you are planning to use this API for only one catalog item with limited fields/variables to retreive.

If you configure a scripted rest API, you can leverage it for all request items which is a more stable and configurable solution.

SwapnaAbburi_0-1669722080047.png

 

View solution in original post

10 REPLIES 10

bist-van
Tera Expert

Hi Akshaya,

 

As I have understood you would like to get all the variables from a single RITM. If you would like to make a generic solution, not just a quick one-time use only, I would go with Scripted REST APIs, there's a great guide for that here:

SN Pro Tips — Scripted REST APIs & Retrieving RITM Variables via SRAPI

 

Also, the issue in your request would be a missing .sys_id parameter.

Instead of querying request_item=RITMID, query request_item.sys_id=RITMID. This should yield the results you are looking for. Full link would look like this, assuming that you are using the table API:

INSTANCE/api/now/table/sc_item_option_mtom?sysparm_query=request_item.sys_id%3D[RITMID]

Hope I could help!

 

Best Regards.

István