- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Is it possible to create a scripted REST API method with a dynamic URL?
For example, using this URL to make the REST call:
https://<servicenowURL>/api/x_uob15_living/ticket/TCK12345/comments
Where TCK12345 is the reference number of an existing ticket and will change depending on the ticket being queried.
I tried specifying the relative URL of the method as /${ticket_id}/comments, but it was not accepted.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
@Colleen ,
In ServiceNow, when creating a Scripted REST API, it is possible to have dynamic segments in your URL path like your example with a variable ticket ID — but it must be done using path parameters.
You should define your relative path using curly braces {} to indicate a path parameter. So for your case:
/{ticket_id}/comments
Then, inside your Scripted REST Resource, you can access the dynamic value using the request.pathParams object.
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
why not?
It should work when you use GET Method.
you can grab the ticket_id in scripted rest api script
check solution shared below from me
How to use Query Parameter of Scripted API
there are lot of OOTB Scripted REST API which you can check how to grab it
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
You can do this in Flow Designer Action easily rather than Scripted REST API. You can do same function in Scripted REST API as well.
Please see below for sample action and how to set it up,
You can pass the reference incident from main flow and call it in action.
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan