1

I have already created a Query Activity in Salesforce marketing cloud using the SOAP API and it was success. My next step to update the SQL Query in the Query Activity using SOAP API. Unfortunately in the documentation, they haven't provided the SOAP envelop format.

Documentation : https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/updating_a_query_activity.htm

So far I tried something like below and it was not success.

<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
    <wsse:Security soap:mustUnderstand="1">
        <wsse:UsernameToken>
            <wsse:Username>myUsername</wsse:Username>
            <wsse:Password>MyPassword</wsse:Password>
        </wsse:UsernameToken>
    </wsse:Security>
</soap:Header>
<soap:Body>
    <UpdateRequest
        xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <Objects xsi:type="QueryDefinition">
            <PartnerKey xsi:nil="true"></PartnerKey>
            <ObjectID xsi:nil="true"></ObjectID>
            <CustomerKey>1542788641356_QueryActivity</CustomerKey>
            <Client>
                <ID>7665587</ID>
            </Client>
            <Definitions>
                <Definition xsi:type="QueryDefinition">
                    <ObjectID>354afdc3-iida-4c17-fdd7-2d1855rttbea7</ObjectID>
                </Definition>
            </Definitions>
            <QueryText>SELECT firstname,lastname,PersonContactId FROM Distributed_Marketing_Conso_335</QueryText>
            <TargetType>DE</TargetType>
            <DataExtensionTarget>
                <PartnerKey xsi:nil="true"></PartnerKey>
                <Name>1542788641356_DataExtension</Name>
            </DataExtensionTarget>
            <TargetUpdateType>Overwrite</TargetUpdateType>
        </Objects>
    </UpdateRequest>
</soap:Body>

Appreciate your help to find a Working SOAP Envelop format to update the Query Activity.

1 Answer 1

2

While searching a bit more, I could build a working SOAP envelop. Here is the answer :

<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
    <wsse:Security soap:mustUnderstand="1">
        <wsse:UsernameToken>
            <wsse:Username>myUsername</wsse:Username>
            <wsse:Password>myPassword</wsse:Password>
        </wsse:UsernameToken>
    </wsse:Security>
</soap:Header>
<soap:Body>
    <UpdateRequest
        xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <Options></Options>
        <Objects xsi:type="QueryDefinition">
            <Client>
                <ID>9545622</ID>
            </Client>
            <ObjectID>354afdc3-ccda-4g88-bcd7-gf554dd6bea7</ObjectID>
            <QueryText>SELECT firstname,lastname,PersonContactId FROM Marketing_Conso</QueryText>
            <TargetType>DE</TargetType>
            <DataExtensionTarget>
                <PartnerKey xsi:nil="true"></PartnerKey>
                <ObjectID xsi:nil="true"></ObjectID>
                <CustomerKey>1356_DataExtension</CustomerKey>
                <Name>1356_DataExtension</Name>
            </DataExtensionTarget>
            <TargetUpdateType>Overwrite</TargetUpdateType>
        </Objects>
    </UpdateRequest>
</soap:Body>

2
  • did you do this as a patch or a post? Commented Jul 23, 2021 at 17:47
  • 1
    Hi @garek007 I did this as a POST. Its works for POST without any issue. Commented Jul 26, 2021 at 4:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .