extract variable with the new request object

Hi There,

The below is my client request to proxy. Essentially am creating a new request object with myRequest using assign message which should contain the payload sent by the client and trying to extract JSON elements from that newly created myRequest object in extract variable, but I couldn't get the myRequest object to the extract variable. See below for the payload and other necessary info. The bottom line is to extract the JSON elements from the newly created object that I couldn't do work it out.Not sure where am missing.pls advice.

Payload: {"foo": "bar", "hello": "world"}

AssignMessage:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage async="false" continueOnError="false" enabled="true" name="AM-changeReqName"> <DisplayName>AM-changeReqName</DisplayName>

<AssignTo createNew="true" transport="http" type="request">myRequest</AssignTo> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>

<AssignVariable>

<Name>myRequestVar</Name> <Ref>request.content</Ref>

</AssignVariable>

ExtractVariable:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="EV-jsonInputValidation"> <DisplayName>EV-jsonInputValidation</DisplayName> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>

<Source clearPayload="false">myRequest</Source>

<JSONPayload>

<Variable name="name1"> <JSONPath>$.foo</JSONPath> </Variable>

<Variable name="name2"> <JSONPath>$.hello</JSONPath> </Variable>

</JSONPayload>

</ExtractVariables>

0 2 118
2 REPLIES 2

Your AssignMessage policy is setting a flow variable named myRequestVar

Your extract variable is trying to use myRequest as a source.

These should be matching. I'd recommend not using "Var" in your variable name.

Also, your AssignTo and AssignVariable are for different things - a request/response object to be manipulated via add/set, the latter for flow variables.

eg id expect this to work

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage async="false" continueOnError="false" enabled="true" name="AM-changeReqName"> <DisplayName>AM-changeReqName</DisplayName>

<AssignVariable>

<Name>myRequest</Name> <Ref>request.content</Ref>

</AssignVariable>

Just trying to understand, did you mean what cited for assign message and extract variable is incorrect,that wont work? I agree that I can rename myRequestVar with myRequest. Could you pls provide the corresponding extract variable policy too here to get the assignmessage myRequest object in to Extract variable.