How to hit dynamic End point URL along with parameters from service-now

Lucky1
Tera Guru

Hello all,

 

Using a scripted REST API, a catalog item request will be created.

The customer enters a URL along with some parameters in a variable.

So, I have configured a rest outbound message and calling that from business rule before task closure.

 

Now, the customer is saying that he will change the Base URL every time he creates a request in service-now and we need to hit that URL.

So, we cannot use rest outbound message here. 

So, can someone tell me how to hit the dynamic URL every time we receive it in a catalog item variable??

What script we need to write?

 

 

Regards,

Lucky

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Lucky1 

you can set the endpoint using RESTMessageV2 this function setEndpoint(), don't configure endpoint there in REST Message or whatever you give it will pick based on what you pass in this method in script

RESTMessageV2 - Scoped, Global 

AnkurBawiskar_0-1743998427721.png

OR Best Way

1) Don't use REST Message and don't create REST Message, you can still consume the endpoint and send request without creating a REST Message in system using Recordless REST Message

2) check this link

Recordless RESTMessageV2 example 

AnkurBawiskar_1-1743998532383.png

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

18 REPLIES 18

Shivalika
Mega Sage

Hello @Lucky1 

 

You can just use this ${variable_name} in your endpoint URL 

 

And substitute variables in the related list - there you can pass values, in the preview script usage - you will get ""sn_ws.setParameter....."" - which will help you in dynamic parameters. 

 

You can refer this video for dynamic parameters also - 

https://youtu.be/Hnndv5IEZ_E

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

Hello SHivalika,

 

The End point URL is not fixed.

He might change the URL sometimes and create a request. And this is not Service-now URL.

And also, he might add new parameters.

 

So, there cannot be a unique REST outbound message for this right?

We are hitting his webhook URL. and it may change.

 

 

So, how to proceed here, we need to hit his webhook URL and also along with the parameters he mentioned in the URL.

 

 

 

Regards,

Lucky

Hello @Lucky1 

 

You can pass the URL - complete URL also as a query parameter. If you are just doing GET or POST - the endpoint hardly matters - you can set it dynamic - unless you have done use of the endpoint - it won't matter. You can completely out it dynamic. And yes I know this is not servicenow URL - whether servicenow or not - it doesn't matters - URL is an endpoint and can be dynamic. 

 

You can share me some screenshots I will be able to explain better. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

 

 

Sure SHivalika,

 

I will share the screen shots of REST outbound message I created to trigger the Web hook URL, and also the query parameters IN SOME TIME.

 

Thanks a lot.

 

 

Regards,

Lucky