Fetch target server dynamically in assign message policy

Hi Team,

I have an assign message policy which sets target url and refers to complete backend target url hard coded to <value> tag in another assign message policy, but I do not want to hard code it, rather it should pick the target server value from the target server config in env->target server.

How can I achieve this.(I want to use assign message policy only, if possible)

Also, the targetURL entity in Target request flow is NA, not sure why is that, eventhough I am adding httptargetconnection tag in Target Endpoint. PFA 

IMG_20230519_172624.jpg

IMG_20230519_172518.jpg

0 2 206
2 REPLIES 2

You cannot  do that, not directly. 

From the description you offered, you are trying to use the data configured for the target server, as the input to a dynamic assignment in AssignMessage. 

It is possible to use something like the JavaScript policy to select a random value from a list, or even use a weighted random selection.  But that assumes the data is available to the API proxy - either hardcoded in the JavaScript policy itself, or in a property, or in a KVM, etc. The targetserver data though, is not available to the proxy, directly.  It is available (readable) only administratively.  

So if you want to use targetserver, then let Apigee do the selection.

If you want your own proxy logic to do the selection, then do not use the targetserver mechanism.  

One more thing: WHY do you want to do the thing you describe?  The set of requirements you have laid out for the solution is a little.... _specific_.  Why? 

If I am removing the assign message policy where target url (http)is hard-coded and letting apigee to take up the target server itself, then i get error of 503 service temporarily unavailable.