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

Unable to change target.url in Assign message

Not applicable

I tried below ways to change the target.url.But they are not working.

There is no change in the target endpoint and only resource path is the change from proxy request.

I am using Assign Message policies in Target Preflow.

1)Using Set path as below,

<Set><Path>/a/b</Path></Set>

But Set path is not working.Looks like the bug still exists (REF).Please let me know when this can be resolved.

2)Setting {target.url} in Assign message as below,

<AssignVariable> <Name>target.url</Name> <Value>{target.url}/a/b</Value> </AssignVariable>

But this is not working.Showing "not equal to" in Trace while assigning.

target.url ≠ {targeturl}/a/b/c

3)Saved {target.url} in a Assign Message and using it as a variable in another Assign message.

This one has same impact as the 2nd method.

4)Only method that is working is,using entire url including target.url hardcoded as below,

<AssignVariable> <Name>target.url</Name> <Value>http://www.xyz.com/a/b/c</Value> </AssignVariable>

I dont want to use javascript if I can do this through Assign message.I dont want to hardcode the entire target endpoint in Assign message when I have a variable {target.url}.

Please let me know if these are expected and I have no other choice but to hardcode the entire url.

1 15 1,858
15 REPLIES 15

adas
New Member

@RK4 Unfortunately, this is the expected behaviour. There's an open bug wrt setting target.url using assign message. You can set the complete target.url but not partially. To workaround this problem, you need to use javascript. Here's an example:

context.setVariable("target.copy.pathsuffix", false);
var targetserver = context.getVariable("target.url");
var targetpathsuffix = "/rest/api/2/search"
var targeturl = targetserver + targetpathsuffix
context.setVariable("target.url", targeturl);

In this example, I am getting the target.url dynamically and then adding a path suffix to it. I am also disabling the target.copy.pathsuffix so that the request path suffix does not get added to the target.

Ok @arghya das .Thankyou...

When that Set Path bug will be resolved?This is something like one of the feature of Assign message missing..If this is fixed,we can avoid using javascript.

But by using this code, I am getting the value of targetserver variable as null. Could you please suggest.

I have the same problem @arghya das. I am using a javascript policy in the Target endpoint pre-flow. but I get the target.url value as null.

Has this been resolved yet. I also get same issue with target.url not equals in trace.

Can you please share the solution of this? I'm facing the same issue...

Any solution for this yet?

Hello @arghya das @Anil Sagar @Dino

How the properties of target connection like below behaves in this case of dynamic target.url?

Whether they will come into picture or not?

<Properties> <Property name="use.proxy">false</Property> <Property name="response.streaming.enabled">true</Property> <Property name="request.streaming.enabled">true</Property> <Property name="allow.http10">true</Property> <Property name="io.timeout.millis">3600000</Property> <Property name="allow.http.method.OPTIONS">false</Property> <Property name="allow.http.method.HEAD">false</Property> <Property name="allow.http.method.TRACE">false</Property> <Property name="allow.http.method.PATCH">false</Property> </Properties>

Regards,

Ch.Venkat.

Not applicable

I've used method #4 and works fine. Is there any reason why this doesn't work for you?

@Diego Zuluaga ,I dont want to hard code the entire url.When the same code goes to production,then I will have to touch the Assign message policy to make the change.It should be like I can make the modification only in Target Endpoint rather than making the change inside policies for environment level configurations.

With method #4 you can still reference variables. So, if you want to dynamically change a value without redeploying your API proxy, you can reference a KVM, and then use it from AssignMessage policy.

Okay @Diego Zuluaga .That sounds a good idea for me...Thankyou

adas
New Member

@Sonali Morey you need to do this in the target preflow. If you still have issues, can you send me your sample proxy bundle. I can try and look at that.

@arghya das

Is the <Set> <Path> issue fixed in Assign message?