How to create dynamic target end points in a SC policy ?

Not applicable

Hi,

My target end point is dynamic.I have go through this

( https://community.apigee.com/questions/24408/how-can-i-dynamically-set-the-url-for-a-servicecal.html ) reference,but it is not working for me.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="myServicePolicy">
<DisplayName>test</DisplayName>
<Properties/>
<Request clearPayload="true">
<Set>
<Headers>
<Header name="Authorization">Bearer {shareFiles.auth_token}</Header>
</Headers>
<Verb>GET</Verb>
<Path>{sc_urlPath}</Path>
</Set>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
</Request>
<Response>calloutResponseDownload</Response>
<HTTPTargetConnection>
<Properties/>
<URL>https://{hostName}{downloadUrl}</URL>
</HTTPTargetConnection>
</ServiceCallout>

In my JS Policy I have added like this

context.setVariable('hostName', hostName);
context.setVariable('downloadUrl', downloadUrl);

I have also tried the following method

var siteUrl = 'https://' + hostName + downloadUrl;
context.setVariable("servicecallout.myServicePolicy.target.url", siteUrl);
Solved Solved
0 1 832
1 ACCEPTED SOLUTION

sidd-harth
Participant V

Hi @Geo V L, as per your previous comments, if it is only HTTPS protocol then it's straight-forward. No need to use JS policy.

You can follow Diego's answer in that post.

https://{target_hostname}/{target_path}</URL>;

You need to be setting these variables (target_hostname}&{target_path}) before SC policy.

View solution in original post

1 REPLY 1

sidd-harth
Participant V

Hi @Geo V L, as per your previous comments, if it is only HTTPS protocol then it's straight-forward. No need to use JS policy.

You can follow Diego's answer in that post.

https://{target_hostname}/{target_path}</URL>;

You need to be setting these variables (target_hostname}&{target_path}) before SC policy.