1 year ago

#73104

test-img

soum

How to create XML request payload in mulesoft using transform message

I am trying to build an api that has two HTTP components

-- The first http request acquires an access token from marketing cloud -- The second HTTP component uses that access token and sets it in a xml payload that goes out to marketing cloud to insert a consumer record in the publication list.

Here is the XMl payload

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <s:Header>
        <a:Action s:mustUnderstand="1">Create</a:Action>
        <a:To s:mustUnderstand="1">https://{{org id}}.soap.marketingcloudapis.com/Service.asmx</a:To>
        <fueloauth xmlns="http://exacttarget.com">#[payload.access_token]</fueloauth>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
            <Objects xsi:type="Subscriber">
                <ObjectID xsi:nil="true"></ObjectID>
                <CustomerKey>foobar+subtest@gmail.com</CustomerKey>
                <EmailAddress>foobar+subtest@gmail.com</EmailAddress>
                <Lists>
                    <ID>269</ID>
                    <ObjectID xsi:nil="true">
                    </ObjectID>
                </Lists>
            </Objects>
        </CreateRequest>
    </s:Body>
</s:Envelope>

My flow looks like this

enter image description here

And I am referencing the payload in the last http listener as

enter image description here

But I get failed: bad request (400).

Same request when I send from POSTMAN, works just fine. I acquire an access_token with and then pass the access_token into the second call, in the request body. What am I missing here?

dataweave

mulesoft

mule4

0 Answers

Your Answer

Accepted video resources