I want to assign backend url dynamically for service call out testing

I am uploading my code for assigning dynamic url in service call out.Can anybbody give me a better code for the same.

In the code we cant change dynamically http to https.Is this the best option or other options are there??

Please anybody have a working example of a better version?

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="Service-Callout-1">
    <DisplayName>Service Callout-1</DisplayName>
    <Properties/>
    <Request clearPayload="true" variable="myRequest">
        <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    </Request>
    <Response>calloutResponse</Response>
    <HTTPTargetConnection>
        <Properties/>
        <!--<URL>https://en.wikipedia.org/wiki/JSON</URL>-->
        <!--<URL>https://{mytarget}</URL>-->
        <URL>https://{mytarget}/{myTargetService}</URL>
    </HTTPTargetConnection>
</ServiceCallout>
Solved Solved
0 4 112
1 ACCEPTED SOLUTION

Hi @Vinod Mehta,

Here is the detailed answer for your query. you can use JS policy to make the service callout dynamic.

View solution in original post

4 REPLIES 4

Hi @Vinod Mehta,

Here is the detailed answer for your query. you can use JS policy to make the service callout dynamic.

@Ravindra Singh please give me a working proxy?Not able to execute the same...

Thanks..

sure will share

Here you go with sample proxy servicecallout-demo-rev2-2019-08-11.zip

Note - In JS file I have putup the hardcoded url which we setup in the service callout policy. The URL in service callout policy is just works like a placeholder.

//var urlvalue = context.getVariable('settings_serviceCalloutUrl');
var urlvalue=  'https://webhook.site/eceba9a8-4bd2-4626-b1fd-4b5c350736bd';

Uncomment the context.getVariable line and put the correct variable name which has full endpoint.

Hoping this will clarify this and for more information, please visit the link again which I have shared in the answer already.