Assigning variable to request payload

Not applicable

Hi, I want to send my query as well as JSON payload values to my request payload.

My Extract variable policy is:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="EV-GetStartDate">
    <DisplayName>EV-GetStartDate</DisplayName>
    <QueryParam name="type" type="string">
        <Pattern ignoreCase="true">{type}</Pattern>
    </QueryParam>
    <QueryParam name="index" type="string">
        <Pattern ignoreCase="true">{index}</Pattern>
    </QueryParam>
    <JSONPayload>
        <Variable name="name" type="nodeset">
            <JSONPath>$.query.name</JSONPath>
        </Variable>
        <Variable name="address" type="nodeset">
            <JSONPath>$.query.address</JSONPath>
        </Variable>
    </JSONPayload>
    <VariablePrefix>queryinfo</VariablePrefix>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</ExtractVariables>

My Assign Message policy is:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-AssigningDate">
    <DisplayName>AM-AssigningDate</DisplayName>
    <Set>
        <Payload contentType="application/json">
            {"type":"{queryinfo.type}","index":"{queryinfo.index}","query":{"name":"{queryinfo.name}","address":"{queryinfo.address}"}}
        </Payload>
    </Set>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>

My output is:

{"type":"person","index":"epfo","query":{"name":"","address":""}}

It seems that, query parameters are extracted and it is assigned to request body but JSON payload variables are not get extracted.

How to extract these many number of variables and provide it to the request body?

Thanks in advance

0 3 2,110
3 REPLIES 3

Hi does your request message have a Content-Type header that is application/json.

Do you have an example of your request payload as your policy works for me with query parameters and a json request body