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.

Table API vs scripted REST API

deesha
Tera Contributor

When to use table based API and scripted REST API? Pros and cons for both?  

5 REPLIES 5

jon_adlum
ServiceNow Employee
ServiceNow Employee

For me, I use the table apis for simple actions (create read update delete) on a given table. I leverage scripted api's when I'm creating a more complex action. Scripted API's are much flexible and whether you are leveraging pre built ones, or building your own (in a scoped app maybe), scripted API's are for exposing much more flexible and often more complex functions.

 

For instance a scripted api may perform actions against different tables, whereas a table based api allows you access to a single table (though there may be business rules etc triggered by the action)

 

eg Table API on user table to insert a user

Scripted api for create new user, insert user, adds it to a group, sets the manager, sends an email etc

 

If you let me know what you are trying to accomplish, then I'm happy to help however I can

 

Cheers

Jon

Hi Jon, 

I need to create a Webservice API where input is: Sys ID of any record and output is: all *related* active records to that sys id. The relationships between the tables is maintained in Relationships under system definition.

Could you please guide me how to implement this?

Input: Sys ID of the record
Output: All *RELATED* active records from *VARIOUS* tables (in the following JSON format):
{
"result": [
{
"Sys ID": "5520267",
"CI Name": "Record 1",
"Table Name": "u_table_a"
},
{
"Sys ID": "5520367",
"CI Name": "Record 2",
"Table Name": "u_table_a"
},
{
"Sys ID": "8331210",
"CI Name": "Record 1",
"Table Name": "u_table_b"
},
{
"Sys ID": "8321210",
"CI Name": "Record 2",
"Table Name": "u_table_b"
},
{
"Sys ID": "3042006",
"CI Name": "Record 3",
"Table Name": "u_table_b"
},
{
"sys_id": "4509847",
"CI Name": "Record 1",
"Table Name": ""u_table_c"
}
{
"sys_id": "4509247",
"CI Name": "Record 2",
"Table Name": ""u_table_c"
}
]
}

As you have mentioned in the below thread.

eg Table API on user table to insert a user

do we can only insert the user by using table API, why cannot we user POST method in table API to create a user in the user table, Is it not possible?

 

As you have mentioned in the below thread.

eg Table API on user table to insert a user

do we can only insert the user by using table API, why cannot we user POST method in table API to create a user in the user table, Is it not possible?