Choose different TargetEndpoint on basis of ProxyPathSuffix

Hi

I have a requirement where I need to create one API Proxy with different Proxy Path Suffix (may be three of them), two of them should go to one targetendpoint and one of them to different targetendpoint. How we can achieve the same ?

Example- when

proxy.pathsuffix = /access_token, it should go to targetendpoint - http://test.com/auth/oauth2/access_token

proxy.pathsuffix = /auth_token, it should go to targetendpoint - http://test.com/authn/json/authenticate

Attaching proxy for the same where changes need to be done for handling second part.

Thanks

openam-getaccesstoken-rev2-2017-05-25.zip

0 9 237
9 REPLIES 9

Hi @GAURAV,

How about using an Assign Message policy to assign the required path to a variable like below for each flow :

<AssignVariable>  
<Name>endpointURL</Name>  
<Value>auth/oauth2/access_token</Value><!--Value changes for each flow-->
</AssignVariable>

and then accessing the variable in the Target Endpoint like below:

<HTTPTargetConnection>  
<Properties/>  
<URL>http://test.com/{endpointURL}</URL>
</HTTPTargetConnection>

Hope it helps!

But how to attach on basis of Proxy Path Suffix ?

I meant to use an Assign Message policy for each of the conditional flows. So for each of the condition, the path value would be assigned accordingly.

You can also try using JavaScript policy in the TargetEndpoint Preflow to check the proxy path suffix and assign the target.url accordingly. See here. This might help!

I am trying to avoid JS policy , so do we need two Assign Message Policies for each flow and it should be placed in ProxyEndPoint PreeFlow Steps ?

Yes @GAURAV. If you are going to use Assign Message policy, you would have to attach in each request flow of the conditional flows at ProxyEndpoint. That should work.

Hi @Hadlee N.A

I tried below solution but it's not resolving the variables.

Checked the trace and I saw the request sent to target looks like below

http://test.com:8080/{endpointURL}/authn/oauth2/%7Brequest.queryparam.tenantId%7D/access_token?grant...

Where endpointURL and request.queryparam.tenantId doesn't get replaced with actual values.

Please find attached bundle and trace for reference.

Thanks

openam-getaccesstoken-rev4-2017-05-26.zip

trace-1495758565304.zip

Yes @GAURAV, the trace does not show the replaced value for the variable. I had worked for a similar scenario, and I can see proper response even when the trace does not show the actual value of the variable. I have raised a separate question for this issue here.

I can see that in your proxy you have placed all the Assign Message policies in the PreFlow. Please place them in each of the conditional flows(POST flows) you have and check once like this:

4943-flowassign.jpg

Also I am not sure whether you can refer another flow variable inside the value of the variable.

Hi @Hadlee N.A

Moved both the Assign Message Policies in Request PostFlow for ProxyEndpoint but still it's not working.

Thanks

@GAURAV,

You cannot use a flow variable or other variable as the value to be assigned to a variable. Please refer doc under '<AssignVariable>/<Value> element'.