How to get all columns' metadata(including parent table's) for a given table via REST api?

Viral Raichura
Tera Contributor

I am trying to get a table's columns and metadata information via making REST API request on sys_dictionary:
REST:
"https://ven02248.service-now.com/api/now/v1/table/sys_dictionary?sysparm_fields=element,max_length,internal_type,mandatory,attributes&name=incident"

But it appears, that the response has only the columns of the requested table, and the parent table information is not included.
For example, in the case of "incident" table, it extends the "task" table. When the request is made to the above-quoted endpoint, the response has only the columns specific to "incident" table.

With the research done from my side, I noticed that with the SOAP request, there is a possibility to get all the columns (of both child and parent tables) information
SOAP:
"https://ven02248.service-now.com/incident.do?SCHEMA"


Please guide us on how we can get all column information via REST api.

Thanks & Regards,
KarthicKumar A

1 ACCEPTED SOLUTION

Hi, I I indicated in previous post do not believe that REST defines the need for a default schema, and most platforms do not deliver one (not just ServiceNow) so I would not call it a 'limitation', you have all the fields available to you but you will need to manage your custom solution as a custom solution, not as an OOB solution.
You could utilize 'sys_db_object' to identify the parent a table is extended from (if any).
Then as a child table inherits all the fields of it's parent, which if extended from another table inherits all the fields of it's parent etc etc; in your solution you can map the table extension tree up to it's root and map\assign fields to the child table from it's parent (tree).

View solution in original post

3 REPLIES 3

Tony Chatfield1
Kilo Patron

Hi, Soap and REST are completely different API's and while Soap may provide a schema this is not a requirement for REST.
You don't make it clear why this is needed? but the simple answer is if you need it you can also query for the parent table, there is an expectation that you will be familiar with the structure and requirements of the target platform.

 

Hello Tony,

We are building a service that interacts with ServiceNow via REST APIs.
And we have a use case that requires us to be aware of the schema of a given table.

Consider the following REST API requests:
1. We get the metadata of a table via querying "sys_dictionary", and it returns only the columns of the requested table (and not any of the columns from its parent(s), if exists).
GET https://ven02248.service-now.com/api/now/v1/table/sys_dictionary?sysparm_fields=element,max_length,internal_type,mandatory&sysparm_query=name=<table_name>

2. We get the data/records from the table via Table API, and its response received has all the data from the child and its parent(s) table(s).
GET https://ven02248.service-now.com/api/now/v1/table/<table_name>

Due to this, we are unable to comprehend the schema received for a table against the data received for the table.

 

But it appears from my searching on related info and ServiceNow support's response, that it is a limitation with REST API as of today.

Please correct me if I am missing something.

Thanks in advance,
KarthicKumar A

Hi, I I indicated in previous post do not believe that REST defines the need for a default schema, and most platforms do not deliver one (not just ServiceNow) so I would not call it a 'limitation', you have all the fields available to you but you will need to manage your custom solution as a custom solution, not as an OOB solution.
You could utilize 'sys_db_object' to identify the parent a table is extended from (if any).
Then as a child table inherits all the fields of it's parent, which if extended from another table inherits all the fields of it's parent etc etc; in your solution you can map the table extension tree up to it's root and map\assign fields to the child table from it's parent (tree).