Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to get Target Server Data with JS Policy

Hi,

I'm using AssignMessage policy to create a variable, I need to set the TargetServer URL into this variable.

I'm trying to do this using JS policy, but I don't know how to get that TargetServer to set into the AssignMessage's variable.

Is it possible to do this?

igallardo_0-1695055496577.png

Or maybe if there's another way to do this, I'd appreciate it.

The main idea is not to use "hard corde" url in that policies.

Thanks.

 

Solved Solved
1 5 1,038
1 ACCEPTED SOLUTION

According to the trace you are showing, the JS policy you have is running very early in the request flow.  Apigee does not select the targetserver until it is invoking the targetserver.  Your proxy logic cannot "see" what the target server will be, before Apigee selects it.  You can "see" the selected targetserver, after Apigee has selected it.  The earliest point where this is possible is in the Target Response flow. 

I will repeat my recommendation from my prior post: If you want to perform your own selection of server + path (each server might have a different path), then I suggest that you avoid using the Apigee TargetServer mechanism, and use your own. You could implement that in JavaScript and rely on settings stored in KVM or a .properties file.  If you want to select JUST the server, then the built-in Apigee TargetServer mechanism will be suitable. 

 

View solution in original post

5 REPLIES 5