How to convert XML to x-www-form-urlencoded

Not applicable

Hi All,

I am trying to convert XML into x-www-form-urlencoded and send it as a Payload.

But not succesfull so far , Can anyone please help me out how can i convert my XML to x-www-form-urlencoded in Apigee Proxy ??

TIA

Solved Solved
0 6 6,256
1 ACCEPTED SOLUTION

Not applicable

FYI : This Solution works for me.

Attached the XML for others reference .

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="am_setLogFireTargetParams" contentType="application/x-www-form-urlencoded">
    <DisplayName>am_setLogFireTargetParams</DisplayName>
    <Set>
        <Headers>
            <Header name="Authorization">Basic cvbcfb==</Header>
        </Headers>
        <Verb>POST</Verb>
        <FormParams>
            <FormParam name="xml_data">{logfire_xml}</FormParam>
        </FormParams>
    </Set>
    <AssignVariable>
        <Name>target.copy.pathsuffix</Name>
        <Value>false</Value>
    </AssignVariable>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="false" transport="http" type="request" content-type="application/x-www-form-urlencoded"/>
</AssignMessage>

View solution in original post

6 REPLIES 6

Former Community Member
Not applicable

Use the Extract Variables policy and extract (via XPath) the XML elements to variables. Then use Assign Message policy to add FormParam fields with those variables.

Hi @Srinandan Sridhar ,

Thanks for the reply.

Do you have any sample, how to use FormParam in Assign message Policy ?

That would be more precise for me.

Former Community Member
Not applicable

Not applicable

Hi @Srinandan Sridhar,

Please check below, How would i send "xml_encoded" as a payload after ?

<FormParams>     
        <FormParam name="xml_encoded">{xml_data}</FormParam>     
</FormParams>

Not applicable

FYI : This Solution works for me.

Attached the XML for others reference .

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="am_setLogFireTargetParams" contentType="application/x-www-form-urlencoded">
    <DisplayName>am_setLogFireTargetParams</DisplayName>
    <Set>
        <Headers>
            <Header name="Authorization">Basic cvbcfb==</Header>
        </Headers>
        <Verb>POST</Verb>
        <FormParams>
            <FormParam name="xml_data">{logfire_xml}</FormParam>
        </FormParams>
    </Set>
    <AssignVariable>
        <Name>target.copy.pathsuffix</Name>
        <Value>false</Value>
    </AssignVariable>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="false" transport="http" type="request" content-type="application/x-www-form-urlencoded"/>
</AssignMessage>

Thank you @gautam1 for sharing solution with community, I am sure it will be helpful for others.