0

I am using the Marketing Cloud SOAP API to update some data within my Data Extension using the following payload.

Header:

POST /Service.asmx HTTP/1.1
Host: myserverid.soap.marketingcloudapis.com
Content-Type: text/xml
SOAPaction: Update

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>
   <fueloauth>MYKEYGOESHERE</fueloauth>
 </s:Header>
<s:Body>
  <UpdateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
    <Options>
      <SaveOptions>
        <SaveOption>
          <PropertyName>DataExtensionObject</PropertyName>
          <SaveAction>UpdateAdd</SaveAction>
        </SaveOption>
      </SaveOptions>
      <RequestType>Asynchronous</RequestType>
    </Options>
    <Objects xsi:type="DataExtensionObject">
        <CustomerKey>MYDEKEY</CustomerKey>
        <Properties>
          <Property>
            <Name>subscriberkey</Name>
            <Value>TestSubscriberKey123</Value>
          </Property>
          <Property>
            <Name>mobilenumber</Name>
            <Value>08123456798</Value>
          </Property>
          <Property>
            <Name>firstname</Name>
            <Value>Janet</Value>
          </Property>
          <Property>
            <Name>lastname</Name>
            <Value>Doe 123</Value>
          </Property>
        </Properties>
    </Objects>
  </UpdateRequest>
</s:Body> 
</s:Envelope>

However I get a Bad Request error.

EDIT: Updated 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>
   <fueloauth>MYSECRETKEY</fueloauth>
 </s:Header>
<s:Body>
  <UpdateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
    <Options>
      <SaveOptions>
        <SaveOption>
          <PropertyName>DataExtensionObject</PropertyName>
          <SaveAction>UpdateAdd</SaveAction>
        </SaveOption>
      </SaveOptions>
      <RequestType>Asynchronous</RequestType>
    </Options>
    <Objects xsi:type="DataExtensionObject">
        <CustomerKey>MYDEKEY</CustomerKey>
        <Keys>
            <Key>
                <Name>subscriberkey</Name>    
                <Value>TestSubscriberKey123</Value>
            </Key>
        </Keys>
        <Properties>
          <Property>
            <Name>subscriberkey</Name>
            <Value>TestSubscriberKey123</Value>
          </Property>
          <Property>
            <Name>mobilenumber</Name>
            <Value>08123456798</Value>
          </Property>
          <Property>
            <Name>firstname</Name>
            <Value>Janet</Value>
          </Property>
          <Property>
            <Name>lastname</Name>
            <Value>Doe 123</Value>
          </Property>
        </Properties>
    </Objects>
  </UpdateRequest>
</s:Body> 
</s:Envelope>

1 Answer 1

0

I believe you are missing the 'keys' node for this envelope:

<Keys>
    <Key>
        <Name>Subscriberkey</Name>    
        <Value>mySubkeyValue</Value>
    </Key>
</Keys>

Which should be above the 'Properties' node like so:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Header>
    <fueloauth>{{accessToken}}</fueloauth>
  </soapenv:Header>
  <soapenv:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <UpdateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <Options>
            <SaveOptions>
               <SaveOption>
                  <PropertyName>DataExtensionObject</PropertyName>
                  <SaveAction>UpdateAdd</SaveAction>
               </SaveOption>
            </SaveOptions>
           </Options>
          <Objects xsi:type="DataExtensionObject">
          <CustomerKey>MYDEKEY</CustomerKey>
          <Keys>
              <Key>
                  <Name>Subscriberkey</Name>    
                  <Value>TestSubscriberKey123</Value>
              </Key>
          </Keys>
          <Properties>
              <Name>mobilenumber</Name>
              <Value>08123456798</Value>
            </Property>
            <Property>
              <Name>firstname</Name>
              <Value>Janet</Value>
            </Property>
            <Property>
              <Name>lastname</Name>
              <Value>Doe 123</Value>
            </Property>
          </Properties>
          </Objects>
    </UpdateRequest>
  </soapenv:Body>
</soapenv:Envelope>

The keys are needed to be able to define what is a new record (add) and what is an edit to an existing record (update).

EDIT - I added in the full, working SOAP envelope I used for reference in hopes that some part of it might be the missing piece you need to solve your 'Bad Request' error.

6
  • I have tried this, still seems to be getting Bad Requests, I have even tried removing subscriberkey property out of the <Properties> section as its used as the <Key> but this still returns the same error. Mar 10, 2020 at 17:32
  • @DeploymentFailure - You definitely want to remove the subscriberkey out of properties if it is the key. Try changing 'SOAPAction' in header to 'SoapAction'. Not 100% positive, but I think that is case-sensitive. Mar 10, 2020 at 18:47
  • Tried switching to SoapAction, this has also returned the same response error. Mar 10, 2020 at 22:25
  • @DeploymentFailure - I'll be honest, I don't really know why it would still be tossing that error. Maybe its something with the defining of the Envelope Header and/or Body. I am going to add these into my answer for reference (as it works correctly on my end) and maybe utilizing those will assist in debugging what the heck it is causing your issue. Mar 11, 2020 at 14:04
  • If you could update your answer with the body and header, I'll just try replicating with that. Mar 11, 2020 at 14:31

You must log in to answer this question.

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