How should the authentication be handled on Table API calls within my Scripted REST API?

JennyHu
Tera Guru
Tera Guru

Hi community,

I have a Scripted REST API for a scoped application.   I implemented a Scripted REST API Resource with a number of calls to the Table API to update a number of tables.   For my Scripted REST API, it requires authentication. So when the Scripted REST API is called, username and password are provided.   However, when the Table API endpoints are called within the Scripted REST API, authentication to the endpoints are required again.

How should the authentication be handled on Table API calls within my Scripted REST API?   Is it possible, and follows best practices to pass the username and password I received for the Scripted REST API to the Table API endpoints?

Thanks for any help you can provide.


Jenny

1 ACCEPTED SOLUTION

Mike Allen
Mega Sage

You can set up a Basic Auth Configuration in table sys_auth_profile_basic.   Then put that record in a system property, and call it:



authID = gs.getProperty('basic_auth.profile');



In the script, you can then set:


r.setAuthenticationProfile('basic', authID);



or something like that.


View solution in original post

3 REPLIES 3

Mike Allen
Mega Sage

You can set up a Basic Auth Configuration in table sys_auth_profile_basic.   Then put that record in a system property, and call it:



authID = gs.getProperty('basic_auth.profile');



In the script, you can then set:


r.setAuthenticationProfile('basic', authID);



or something like that.


Hi Mike,



This is exactly what was missing.   I set the authentication profile as suggested and it worked perfectly!



Thanks so much!



Jenny


Hello, 

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? Sample code would be great.

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"
}
]
}