REST-API: How to get a list of fields on a given template?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2019 01:22 PM
I saw this question, but no answer:
How do I get a list of all writable fields for a given table (incident for example) using the REST api
What REST-API can be used to get a list of the fields on a given table or template?
It is possible to find one record in a table (i.e. "incident") and scrape the fields off the record:
GET /api/now/table/incident?sysparm_limit=1
But for a template, the underlying table is not known, therefore I cannot do the above hack.
Please provide a way to query the fields on a given template or table. Field-type would be a bonus! (short-text, long-text, user, group, etc)
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2019 11:41 AM
All fields for tables are in sys_dictionary. All templates are in sys_template. Both are accessible from REST API. sys_template has a dynamic field, called template, that is dependent upon the table that is filled in, so you would be able to see what fields are defined in each template.
What exactly are you looking to do?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2019 05:38 AM
Thanks for the reply.
I get 403 for a user with rest_service and scn_platform_rest_access roles.
GET /api/now/table/sys_dictionary?sysparm_display_value=true
However, this succeeds:
GET /api/now/table/sys_template?sysparm_display_value=true
It seems the user must be an admin to read the sys_dictionary table. Funny that certain sys_* tables are blocked from rest_service role but others are not (sys_user, sys_user_group, etc are ok).
I am hoping to provide a dynamic integration of ServiceNow with a product I am developing. I would like to give my product's admin a choice of tables and templates to use for the mapping. Once the table/template is chosen, the product queries for a list of fields on the selected table or template. It would be great to know what field can be modified by REST and what the field type is. The idea is to give the my product's admin a way to map a whole bunch of fields from my product into the short_description and description fields of ServiceNow plus allow the admin to pre-fill other fields too. Once configured, any user of my product can then create a SN ticket from my product's data.
Using an "admin" SN role seems overkill for what I am hoping to achieve.
Again, thanks for the reply. I hope this will benefit other developers.