store request body in variable and use it later.

Not applicable

I have an proxy. i am using service call out and JavaScript policy.

Here is my requirement.

1. user sending one Json request body i want to store this request in variable. use is later.

2. I have Service call out policy and constructing new json request for callout. getting bool value true/false

3. Now after callout bool value true I need to pass same request to which we have saved at point one.

4. But My request is always override with point 2 request (service callout request).

I am using java script to save and create request.

Saving Old request into variable like(at point 1)

context.setVariable("UserAccess.Request",'request.content');

setting new request in Service callout (Point 2).

var finalRequest='';

finalRequest={"username"="abc"}

context.setVariable("request.content", JSON.stringify(finalRequest));

Now i am trying to use UserAccess.Request variable value but that is override but new request automatically

Plz help

0 1 1,440
1 REPLY 1

@Madhav , Looks like you are using "request" as a variable in both the service callout policies. hence your original payload is getting overwritten. Pls follow the below steps to achieve your requirement.

  1. Add SC policy in preflow to call out target 1, ensure request variable shouldn't be "request" and construct the payload in the same policy.
  2. Add extract variable policy in preflow to extract the response parameters
  3. Add SC policy in postflow to callout target 2 and use "request" as your variable