DiscoveryAPI: in which scope shoudl 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!
1 REPLY 1

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: