Discovery patterns
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
How can we create a discovery pattern that uses predefined REST message?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi @tarekbenhnia ,
Try below steps:
1. Create rest message
System Web Services → Outbound → REST Message
Make sure:
-
Endpoint is working
-
Authentication configured
-
HTTP Method created (GET/POST etc.)
-
Test response returns JSON/XML
Example:
REST Message Name: My_Custom_API
Method Name: getServerDetails
2.Create discovery pattern:
Discovery Definition → Patterns
Create new or edit existing:
-
CI Class
-
Identification Section
-
Exploration Section
3. Add script in pattern to call rest message
Add a Script Operation
Inside Pattern:
👉 Add Step → Operation = Script:
var r = new sn_ws.RESTMessageV2('My_Custom_API', 'getServerDetails');
// Example parameter
r.setStringParameterNoEscape('hostname', pattern.ciData.fqdn);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.info("REST Status: " + httpStatus);
gs.info("REST Response: " + responseBody);
// Parse JSON
var json = JSON.parse(responseBody);
// Map values to pattern attributes
pattern.ciData.os_version = json.osVersion;
pattern.ciData.serial_number = json.serial;
4.map fields
5. Map Data to CI Attributes
Inside Pattern:
- Go to Attributes Section
- Use pattern.ciData.field_name
example:
pattern.ciData.cpu_count
pattern.ciData.memory
pattern.ciData.manufacturer
If my response helped, please hit the 👍Thumb Icon and accept the solution so that it benefits future readers.
Regards,
Pratik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago - last edited 4 weeks ago
1. Create REST Message First
Navigate:
System Web Services → REST Message
-
Create new REST Message
-
Add HTTP Method (GET/POST)
-
Test it → make sure response works
2. Create / Open Discovery Pattern
Navigate:
Discovery → Patterns
-
Open existing pattern OR create new
-
Add new Step
3. Add Step Type = “REST”
In Pattern Step:
-
Operation = REST
-
REST Message = Select your predefined REST
-
HTTP Method = Choose method you created
No scripting needed.
4. Parse Response
Next Step:
-
Add Parse Variable / JSON Parse
-
Map response fields to variables
Example:
-
response.version → version -
response.name → ci_name
5. Update CI Attributes
Add Step:
-
Set Attribute
-
Map parsed variables to CI fields
6. Test Pattern
-
Use Quick Discovery
-
Check ECC Queue / Pattern Logs
✔️ If this solves your issue, please mark it as Correct.
✔️ If you found it helpful, please mark it as Helpful.
—
Shubham Jain

