DiscoveryAPI: in which scope should we create a Scripted REST API to trigger Discovery

danielherre
Giga Guru
Hi ITOM Community,
We are implementing an automation for VM onboarding (virtual machines are created by an external orchestrator). As part of this automation, the orchestrator needs to call ServiceNow to trigger Discovery for the newly created VM(s), so we populate the manual attributes as part of the orchestration.

To achieve this, we plan to build a Scripted REST API endpoint that the orchestrator can invoke, and from that endpoint we would programmatically start a Quick Discovery for the virtual machine IP address.
From the ServiceNow API Reference, it looks like the right approach is to call the DiscoveryAPI (Scoped) methods in the sn_discovery namespace. Specifically, sn_discovery.DiscoveryAPI.discoverIpAddress(ipAddress, application, source) .

Is there any recommended / leading practice on whether a Scripted REST API that triggers Discovery should be created:
  • in Global scope, or
  • in a custom scoped application ?
We want to avoid upgrade issues and follow a stable approach but we also don’t want to run into scope restrictions or cross-scope access issues when calling DiscoveryAPI.

Thanks in advance! Cheers!
3 REPLIES 3

Tanushree Maiti
Mega Patron

Hi @danielherre 

 

To use the DiscoveryAPI class within a Scripted REST API, you should work in the Global scope

 

Refer : KB0830714 [Discovery API] How to utilize DiscoveryAPI scriptable API in REST API Explorer (discoverI... 

 

Note: If needed, you can add a cross-scope privilege in ServiceNow when a scoped application needs to read, write, create, delete, or execute scripts on a resource

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

danielherre
Giga Guru

Thanks for the reply @Tanushree Maiti. That information about the API itself I have already checked it, my specific question si how to identify if it need to global or not. Only information I see is DiscoveryAPI mentions "This class runs is in the sn_discovery namespace." <- how can I select the appropiate scope, is there any guidance from this statement?

Hi @danielherre 

 

We have a catalog in client instance ( in global scope) which is having a process flow that initiate discovery (in Workflow). It is running fine and using Discovery api from sn_discovery namespace.

 

sn_discovery namespace is a package with discovery api provided by Servicenow.

In global scope, if you open script include and search script by "sn_discovery" , lots of script include you will find.

e.g from a OOB script include:

 

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: