Post method using Rest Api Explorer using 'Resource Inventory Open API'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
20 hours ago
Hello,
I am using 'Resource Inventory Open API' to get the records with the help of 'sys_id', now I need to do the same by using 'name' instead of 'sys_id'. My requirement is to use get/put/post method in 'Resource Inventory Open API' without using the 'sys_id'.
Please suggest the possible ways to do so..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @RupaliJ ,
By default, the Resource Inventory Open API is designed to use sys_id as the unique identifier for GET/PUT/POST operations. If you want to work with name instead, you cannot directly replace sys_id in the endpoint — instead, you need to query by name (using filters) or extend the API schema with an extension point to accept name as a key.
-> Query by name filter :
Use the GET method with a query parameter, for example:
GET /api/sn_tmt_resource/resource-inventory?name=Router123This retrieves the record(s) matching the name field, and you can then use the returned sys_id for PUT/POST.
Response:
{
"result": [
{
"sys_id": "abcd1234efgh5678ijkl9012mnop3456",
"name": "Router123",
"status": "active"
}
]
}
Once you have the sys_id, you can perform updates or create related records.
Example PUT request (update record):
PUT /api/sn_tmt_resource/resource-inventory/abcd1234efgh5678ijkl9012mnop3456
Content-Type: application/json
{
"status": "retired"
}
Script Include extension The Resource Inventory Open API supports extension points. You can extend the schema to allow name as a valid identifier. This requires creating a Script Include that maps name to sys_id internally.
Custom wrapper API Build a custom REST API in ServiceNow that accepts name as input, looks up the corresponding sys_id, and then calls the Resource Inventory Open API behind the scenes. This is useful if your consumers prefer working with names.
Important Notes:
Uniqueness of name: If multiple records share the same name, the GET query will return multiple results. You’ll need to handle this in your logic (e.g., pick the right one based on additional filters like location or status).
Best practice: Always resolve name → sys_id before performing updates/deletes.
Customization option: If you want to avoid this two‑step process, you can extend the API with a Script Include or build a wrapper API that accepts name directly and internally resolves it to sys_id.
Thanks,
Ratnakar