1

I am trying to retrieve sent data using SOAP API. My header is: Content-Type text/xml SoapAction Retrieve

I am calling https://mc....soap.marketingcloudapis.com/Service.asmx

Below is my envelope:

<?xml version="1.0" encoding="utf-8"?>
<soapenv: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">
   <soapenv:Header>
      <fueloauth xmlns="http://exacttarget.com">xxxxTOKENxxxx</fueloauth>
   </soapenv:Header>
   <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <RetrieveRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
            <ObjectType>Send</ObjectType>
            <Properties>ID</Properties>
            <Properties>EmailName</Properties>
            <Properties>Subject</Properties>
            <Properties>SendDate</Properties>
            <Properties>FromName</Properties>
            <Properties>FromAddress</Properties>
            <Properties>UniqueOpens</Properties>
            <Properties>UniqueClicks</Properties>
            <Properties>Unsubscribes</Properties>
            <Properties>NumberSent</Properties>
            <Properties>NumberDelivered</Properties>
            <Properties>NumberErrored</Properties>
            <Properties>NumberExcluded</Properties>
            <Properties>HardBounces</Properties>
            <Properties>SoftBounces</Properties>
            <Properties>OtherBounces</Properties>
         </RetrieveRequest>
   </s:Body>
</soapenv:Envelope>

And I am getting this 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>

Can anybody please help? What am I doing wrong? Thank you

1 Answer 1

0

EDIT

I believe the major issue asside from RetrieveRequestMsg is that you are using soapenv: for envelope, but showing s: on your body nodes. e.g. <s:Body> should be <soapenv:Body> and same with the closing tag.


I am not sure why you are getting an HTML response. I would verify your URL - as the response to the Service.asmx should return XML.

e.g.

<?xml version="1.0" encoding="utf-8"?>
<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>
        <wsa:Action>RetrieveResponse</wsa:Action>
        <wsa:MessageID>XXXXXXXXXX</wsa:MessageID>
        <wsa:RelatesTo>XXXXXXXXXXX</wsa:RelatesTo>
        <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
        <wsse:Security>
            <wsu:Timestamp wsu:Id="Timestamp-f4397fef-bcc1-419a-aba7-5b46d0dd6fea">
                <wsu:Created>2019-09-10T14:45:16Z</wsu:Created>
                <wsu:Expires>2019-09-10T14:50:16Z</wsu:Expires>
            </wsu:Timestamp>
        </wsse:Security>
    </soap:Header>
    <soap:Body>
        <RetrieveResponseMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
            <OverallStatus>Error</OverallStatus>
            <RequestID>XXXXXXXXXXX</RequestID>
        </RetrieveResponseMsg>
    </soap:Body>
</soap:Envelope>

But likely to resolve your issue you need to wrap your RetrieveRequest node inside a RetrieveRequestMsg node.

For example:

  <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
     <RetrieveRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <ObjectType>Send</ObjectType>
        <Properties>ID</Properties>
        <Properties>EmailName</Properties>
        <Properties>Subject</Properties>
        <Properties>SendDate</Properties>
        <Properties>FromName</Properties>
        <Properties>FromAddress</Properties>
        <Properties>UniqueOpens</Properties>
        <Properties>UniqueClicks</Properties>
        <Properties>Unsubscribes</Properties>
        <Properties>NumberSent</Properties>
        <Properties>NumberDelivered</Properties>
        <Properties>NumberErrored</Properties>
        <Properties>NumberExcluded</Properties>
        <Properties>HardBounces</Properties>
        <Properties>SoftBounces</Properties>
        <Properties>OtherBounces</Properties>
     </RetrieveRequest>
  </RetrieveRequestMsg>

The above ran successfully for me, where your example one failed as you stated.

6
  • Is there a particular reason that this was downvoted? I provided a solution that successfully solves the issue. Please provide context on what you felt was inappropriate or incorrect. Commented Sep 10, 2019 at 16:39
  • 1
    Thank you I will try this. It wasn’t me who downvoted your anwser.
    – julia2019
    Commented Sep 11, 2019 at 6:37
  • I tried wrapping everything in RetrieveRequestMsg node but still getting the same error. What URL are you using?
    – julia2019
    Commented Sep 11, 2019 at 6:58
  • the url provided inside the UI: https://mxxxxxxxxxxxxxxx.soap.marketingcloudapis.com/Service.asmx. Are you using POST on your call? I tried it with GET and got the same error you did. Perhaps its the method? Commented Sep 11, 2019 at 12:54
  • 1
    That is because you are using soapenv: for envelope, but showing s: on your body nodes. e.g. <s:Body> should be <soapenv:Body> and same with the closing tag. Commented Sep 12, 2019 at 17:01

You must log in to answer this question.

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