Hi
I have a TargetServer set up to allow me to redirect API calls to the relevant back end API depending on the environment. My Target Endpoint is correctly redirecting API calls to this url, but the problem comes when I want to change the destination path.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="Insurance">
<Description/>
<FaultRules/>
<PreFlow name="PreFlow">
<Request/>
<Response/>
</PreFlow>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
<Flows>
......
</Flows>
<HTTPTargetConnection>
<SSLInfo>
<Enabled>true</Enabled>
</SSLInfo>
<LoadBalancer>
<Server name="Insurance"/>
</LoadBalancer>
<Path>/api{targetpathsuffix}</Path>
<Properties/>
</HTTPTargetConnection>
</TargetEndpoint>
I have an AssignMessage policy that I can use to set the path suffix, and again this works
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="test-redirect">
<DisplayName>test-redirect</DisplayName>
<Properties/>
<AssignVariable>
<Name>target.copy.pathsuffix</Name>
<Value>false</Value>
</AssignVariable>
<AssignVariable>
<Name>targetpathsuffix</Name>
<Value>/eng/test</Value>
</AssignVariable>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>
The issue comes when I try and add a variable into the path. I have a policy to extract the variable (which works) and another AssignMessage policy to add it to the path:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Variables-certificatetenancyId">
<DisplayName>Extract Variables-certificate.tenancyId</DisplayName>
<Properties/>
<URIPath>
<Pattern>/**/tenancy/{tenancyId}/test</Pattern>
</URIPath>
<Source clearPayload="false">request</Source>
<VariablePrefix/>
<variable name="tenancyId"/>
</ExtractVariables>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="insurance-tenancy-certificate-targetURL">
<DisplayName>insurance-tenancy-certificate-targetURL</DisplayName>
<Properties/>
<AssignVariable>
<Name>target.copy.pathsuffix</Name>
<Value>false</Value>
</AssignVariable>
<AssignVariable>
<Name>targetpathsuffix</Name>
<Value>/tenancy/{tenancyId}/test</Value>
</AssignVariable>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>
However this doesn’t write the destination URL correctly:
[http://xxxxxxxx/api/tenancy/%7BtenancyId%7D/test](http://xxxxxxxx/api/tenancy/%7BtenancyId%7D/test)
Does anyone have any ideas as to why it won’t translate the Id correctly?
Many thanks
Simon