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

Issue with JS Code in apigee

Hi

I’m badly stuck with one issue right now, if you can please shed some light. Initially I worked with AssignMessage policy using following settings :

<AssignMessage name='AM-1'>
  <AssignVariable> 
    <Name>target.copy.queryparams</Name> 
    <Value>true</Value> 
    <Ref/> 
  </AssignVariable> 
  <AssignVariable> 
    <Name>target.copy.pathsuffix</Name> 
    <Value>false</Value> 
    <Ref/> 
  </AssignVariable> 
  <AssignVariable> 
    <Name>targetpath</Name> 
    <Value>/v5/addresses/find</Value> 
    <Ref/> 
  </AssignVariable>
</AssignMessage>

when calling APIGEE svc, my URL is :

https://apidev02.ftr.com/address/v1/autaddressqualification/v5/addresses/find?address=streeaddress&city=abdc&state=TX&zip=750454

which using AssignMessage policy transforms to :

http://addressqualification.stg.corp.ftr.com/v5/addresses/find?address=streeaddress&city=abdc&state=...54 (which is perfect)

but when I’m trying to do the same thing using JavaScript, as I need to add some conditional logic before setting {targetPath}, using following javascript code :

context.setVariable("targert.copy.pathsuffix", false);

context.setVariable("targert.copy.queryparams", true);

context.setVariable("targetpath", "/v5/address/find");

my outbound URL is getting transformed to :

http://addressqualification.stg.corp.ftr.com/v5/address/find/autaddressqualification/v5/addresses/fi...

Solved Solved
0 8 382
1 ACCEPTED SOLUTION

See here:

https://community.apigee.com/answers/58814/view.html

Also I looked in your code. You have a typo. You are using "targert" and not "target".

your code:

context.setVariable("targert.copy.pathsuffix", false);
context.setVariable("targert.copy.queryparams", false);

Correct code:

context.setVariable("target.copy.pathsuffix", false);
context.setVariable("target.copy.queryparams", false);

View solution in original post

8 REPLIES 8