The CreatorCon Call for Content is officially open! Get started here.

API & Roles or Permissions for Retrieving Mandatory Fields in ServiceNow Incident and Request Tables

gtripathi2612
Tera Contributor

Hi All,

I am writing to inquire about the availability of an API that allows us to retrieve all the mandatory fields from the Incident and Request tables in our ServiceNow instance.

 

It would be helpful for us to programmatically access information about the mandatory fields in these tables.

 

Please let us know if such an API exists, and if possible, provide us with the necessary details to access like Roles to access it as I am trying to call from POSTMAN (grant_type = password) using the User details which is present in ServiceNow Instance which is not having any Roles. 

 

Thank you in advance !!

1 ACCEPTED SOLUTION

Mehta
Kilo Sage

@gtripathi2612 

 

The API to fetch out the mandatory fields is through the table API in which you needs to call "Sys_dictionary" table.

Add Query parameter such as mandatory should be true and name which is a parameter for table to be incident or problem. 

Add this as query parameter as sysparm_query  name=incident^mandatory=true. 

Below are the screenshot from postman: 

Mehta_0-1698137617438.png

This is how Final URL looks Like :  https://<instancename>.service-now.com/api/now/table/sys_dictionary?sysparm_query=mandatory=true^nam...

 

Need to Provide Admin role to the user credentials that you are calling for Oauth where grant_type = password.

 

Please Mark it Correct, If it Resolves your Query.

 

 

View solution in original post

4 REPLIES 4

Anand Kumar P
Giga Patron

Hi @gtripathi2612,

ServiceNow does not have such api to get mandatory fields data instead you can use table api on sys_dictionary table toget all mandatory fields data 

https://<instance>.service-now.com/api/now/table/sys_dictionary?sysparm_query=name=incident^mandatory=true
1. Make sure your POSTMAN user has permissions to access the “sys_dictionary” table.
2. Use the ServiceNow Table API to query the “sys_dictionary” table for mandatory fields.
3. You’ll need to make GET requests to specific API endpoints for each table you’re interested in (e.g., “Incident” or “Request”).
4. Authenticate in POSTMAN using the user’s credentials.
5. The response will contain information about mandatory fields, which you can filter to extract the field names.
6. Note that the exact API details may vary based on your ServiceNow configuration and permissions. Adjust as needed.

Please make this as accepted solution and helpful if it serves your purpose.

Thanks,

Anand

Mehta
Kilo Sage

@gtripathi2612 

 

The API to fetch out the mandatory fields is through the table API in which you needs to call "Sys_dictionary" table.

Add Query parameter such as mandatory should be true and name which is a parameter for table to be incident or problem. 

Add this as query parameter as sysparm_query  name=incident^mandatory=true. 

Below are the screenshot from postman: 

Mehta_0-1698137617438.png

This is how Final URL looks Like :  https://<instancename>.service-now.com/api/now/table/sys_dictionary?sysparm_query=mandatory=true^nam...

 

Need to Provide Admin role to the user credentials that you are calling for Oauth where grant_type = password.

 

Please Mark it Correct, If it Resolves your Query.

 

 

In this even though I see 2 fields as mandatory in UI, I don't get this fields name in Response when I hit the API from POSTMAN.
Any reason though if aware?

Also is it possible to add/update/mandate fields later point of time ?

If yes is it possible to fetch through this same API ?

Thanks again in advance 🙂 

What are the fields you are looking for ?