Apigee Coding Technology

APIGEE-How to perform calculation with JavaScript policy?

In this tutorial we will add two numbers using following APIGEE policies.

  1. Extract Variables Policy
  2. Assign Message Policy
  3. Javascript Policy

First Create No Target API. this code inside looks like this.

Then Add Extract Variables Policy with name “EV-GetParam” into Policies section, The code inside EV-GetParam looks like this.

Now we need to Add Assign Message Policy with name “AM-Print” into Policies section, The code inside AM-Print looks like this.

Finally we are going to add JavaScript Policy with name “JavaScript-1” and code inside policy looks like this.

JavaScript Policy will auto create the associated JavaScript-1.js file in which our java script code goes, and perform calculation as below.

Nice and Clean…Yeah..!

Now browse your proxy link. in my case it will be the proxy link is as follows



Related posts