How to i send request to target endpoint, if i assign variable value as a=10 through javascipt or javacallout policy.

vermagovind92
Participant III

I have a usecase where to send request to target endpoint if i assign variable value as age=10 then it's increment by +5 and result is age=15, similarly when i got a response from target endpoint then again value decrement by -5, and final result will be 10.

Could someone please provide me with samples on this?

How many policies i need to attach?

Follow This User : @Anil Sagar @ Google,Dino-at-Google,@Siddharth Barahalikar

Solved Solved
0 5 271
1 ACCEPTED SOLUTION

@Govind Verma

I am not clear of your use case and what you want to achieve, more elaboration would help.

From what you have described, it sounds (1) initialize a variable => (2) target service will increase its value when it hits target => (3) Apigee decreases its value back down when it is returned from target.

What is the intention behind this ?

Assuming the steps are what I described above, you can

1. JS to initialize the variable in proxy preflow.

2. AssignMessage policy to assign this var to your message header in Target PreFlow.

3. At your backend, extract "myvar" from the header, perform your increment. Assign the value back in the response.

4. ExtractMessage policy in Target PostFlow to get this var back in the response.

5. JS to decrease the variable in Target PostFlow.

Attached a sample proxy FYI.

View solution in original post

5 REPLIES 5

sidd-harth
Participant V

Hi @Govind Verma, your question is not clear. Please update the questions and explain in detail.

@Govind Verma

I am not clear of your use case and what you want to achieve, more elaboration would help.

From what you have described, it sounds (1) initialize a variable => (2) target service will increase its value when it hits target => (3) Apigee decreases its value back down when it is returned from target.

What is the intention behind this ?

Assuming the steps are what I described above, you can

1. JS to initialize the variable in proxy preflow.

2. AssignMessage policy to assign this var to your message header in Target PreFlow.

3. At your backend, extract "myvar" from the header, perform your increment. Assign the value back in the response.

4. ExtractMessage policy in Target PostFlow to get this var back in the response.

5. JS to decrease the variable in Target PostFlow.

Attached a sample proxy FYI.

Thanks @Brendan, my intention is same as you said(i want to do perform same operation). And i import this zip file to my apigee edge account and also created one new proxy and follow the step as you said, but unfortunately this doesn't worked.

Make sure all the relevant endpoints, hostname, etc. points to your account.