how to automate deployment of a Scripted REST API

Dave Oshinsky
Tera Expert

Creation of a Scripted REST API is a manual process, where a web browser user configures the new API. Is it possible to automate this process, so the end user doesn't have to run manual steps? Possible mechanisms would include either executing an existing REST API, or more likely, running a "Fix Script" (server-side script) that configures the new Scripted REST API.

 

When I manually create a Scripted REST API (with global scope) named "clonetable" on my PDI, I'm seeing that the REST endpoint is ending up "/api/1048948/clonetable".  Where does the 1048948 come from? Is it possible for a program to determine that value, so a human does not need to manually lookup the REST endpoint (including the 1048948, for example) and enter the string somewhere?

2 REPLIES 2

Tushar
Kilo Sage
Kilo Sage

Hi @Dave Oshinsky 

 

Apologies on previous response it was from one of the highly customized documentation by one of the leading ServiceNow partner which will require a wider development.

 

I believe there is no built-in ServiceNow API for programmatically creating Scripted REST APIs.

 

Also, I don't find any official ServiceNow API or documentation for creating Scripted REST APIs programmatically using server-side scripts.

 

 

 

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar

Dave Oshinsky
Tera Expert

Thanks @Tushar  for pointing in a useful direction. I don't see any official documentation for GlideScriptedRestApi, so this leads me to more detailed questions like:

1) Is "script_to_handle_api_logic" in your example the name of a "Fix Script"? Or something else?

2) How would "authentication_script" work (what would be its interface)? For some sort of "default" authentication, like "admin" privileges required, how would one set up such default or simplified permissions?

3) Can you refer me to a working example of GlideScriptedRestApi? Googling it doesn't yield much of anything.

 

Regarding sys_rest_message, I don't see anything in that table that deals with the "clonetable" Scripted REST API I've already configured. So, I'm wondering whether that table holds this information, or some other table. These system tables seem to be mostly undocumented, so I have found myself grepping around a complete list of all tables, looking for some clue as to where ServiceNow stores some piece of internal information that I need to access. So far, I haven't found the "magic table" for these Scripted REST API's.