Hi there,
I have some specific requirement. To cut it short, I am setting in java script/AM the below.
context.setVariable("target.url","myapihost.example.com/loyalty/api/v1/courses");
or
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-set-target-url">
<DisplayName>AM-set-target-url</DisplayName>
<AssignVariable>
<Name>target.url</Name>
<Value>myapihost.example.com/loyalty/api/v1/courses</Value>
</AssignVariable>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>
And calling the above variable target.url in the target endpoint with the below setup up, which doens't work looks like the variable {target.url} is not resolving and get service unavailable.Pls advice.
<HTTPTargetConnection>
<URL>https://{target.url}</URL>
</HTTPTargetConnection>
Note: I don't want to do this using a target server; I want to go with the above approach for a reason I will not share. Before providing solution pls try at your end kindly, thanks
Do this:
In actuality, setting target.url
will override the URL element in the TargetEndpoint configuration. The caveat is that you must set the variable in the target request flow. (Preflow or conditional flow or postflow, any of those is fine, but it must be the REQUEST flow in the TARGET endpoint). So, using <URL>httโp://{something}</URL>
is ineffectual , if you are setting target.url
. When I have a proxy that will use dynamic URLs, I use something like this: <URL>httโps://this.will.be/overridden</URL>
.
Secondly, you must set target.url to a url. Not a hostname + path. The full url, including scheme prefix (https://) . I suspect you are seeing "service unabvailable" errors because your target.url variable does not hold a valid url.
This works
<AssignMessage name="AM-set-target-url">
<AssignVariable>
<Name>target.url</Name>
<Value>https://myapihost.example.com/loyalty/api/v1/courses</Value>
</AssignVariable>
</AssignMessage>
coupled with
<TargetEndpoint name="target-1">
..
<HTTPTargetConnection>
<URL>https://this.will.be/overridden/by/assignmessage</URL>
</HTTPTargetConnection>
..