0

I'm trying to get a list of query definitions whose "QueryText" is "like" a certain value. Here's the XML:

<s:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <s:Header>
        <fueloauth>
            accessTokenHere
        </fueloauth>
    </s:Header>
    <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
            <RetrieveRequest>
                <ObjectType>QueryDefinition</ObjectType>
                <Properties>Name</Properties>
                <Properties>CustomerKey</Properties>
                <Properties>DataExtensionTarget.Name</Properties>
                <Properties>DataExtensionTarget.CustomerKey</Properties>
                <Properties>QueryText</Properties>
                <Properties>CategoryID</Properties>
                <Filter xsi:type="SimpleFilterPart">
                    <Property>QueryText</Property>
                    <SimpleOperator>like</SimpleOperator>
                    <Value>Lead</Value>
                </Filter>
            </RetrieveRequest>
        </RetrieveRequestMsg>
    </s:Body>
</s:Envelope>

Here are my headers and the service URL: enter image description here

Yet, when I click Send, I get the below response:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Error</title>
        <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1" />
        <meta name="CODE_LANGUAGE" content="C#" />
        <meta name="vs_defaultClientScript" content="JavaScript" />
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5" />
    </head>
    <body style="margin: 0px; padding: 0px; font-family: Arial;">
        <table style="height:100%; width:100%;" border="0" cellpadding="5" cellspacing="0">
            <tr style="height:10%; background-color:#808080">
                <td>
                    <div style="color:#ffffff; font-size: 16px;">An error has occurred and has been logged by our system.
                        <br />
                        Thank you. </div>
                </td>
            </tr>
            <tr valign="top">
                <td>
                    <div id="errorTxt">&nbsp;</div>
                </td>
            </tr>
        </table>
    </body>
</html>

I've seen a similar Stack Exchange post on this but that didn't help me any. What could I possibly be doing wrong?

1
  • Could it be that you need to set the SOAPAction header to "Retrieve" (with double quotes)? This is how I send my SOAP calls from POSTMan. Jul 30 at 14:02

1 Answer 1

0

I put my template here. I also faced a similar issue like yours. Eventually I managed to make it work by changing the header. Try this out:

<?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">Retrieve</a:Action>
        <a:To s:mustUnderstand="1">https://YOUR_SUBDOMAIN.soap.marketingcloudapis.com/Service.asmx</a:To>
        <fueloauth xmlns="http://exacttarget.com">Access token goes here</fueloauth>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
         <Options>
        </Options>
         <RetrieveRequest>
            <ObjectType>QueryDefinition</ObjectType>
        <Properties>Name</Properties>
        <Properties>CustomerKey</Properties>
        <Properties>DataExtensionTarget.Name</Properties>
        <Properties>DataExtensionTarget.CustomerKey</Properties>
        <Properties>CategoryID</Properties>
        <Filter xmlns:q1="http://exacttarget.com/wsdl/partnerAPI" xsi:type="q1:SimpleFilterPart">
           <q1:Property>QueryText</q1:Property>
           <q1:SimpleOperator>like</q1:SimpleOperator>
           <q1:Value>Contact_Salesforce</q1:Value> <!-- content in the query -->
        </Filter>
         </RetrieveRequest>
      </RetrieveRequestMsg>
    </s:Body>
</s:Envelope>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.