0

I want to add a new row into an existing data extension in SFMC using an API call, I tried using SOAP API, Following are the Error and API request message:

Error : 400 Bad Request.

Request URL : https://{subdomain}.soap.marketingcloudapis.com/Service.asmx

SOAP Envelope : SOAP Envelope

Here, In the soap body I added the customerkey of the data extension and the three properties it has including primary key(Count_Date).I don't see anything wrong with the soap body.

Note : The authorisation part is fine, I verified it by making other requests, And also validated the xml for syntactical errors there are none.

Could someone help me with this.

Reference Used :SFMC Documentation, SFMC Documentation 2

Here is the list of headers I used : enter image description here

I haven't included SoapAction in my request header's, I only set it in the Soap header. But as per your suggestions I tried the other way and still getting the same error. Also tried setting the Content-Type Header to text/xml;charset=UTF-8 still no use.

Note: I actually used the same header's for other requests to the same target, They are working fine, So I don't think the issue is with the header's.

1
  • Are you using Postman for this? If so, I would go to the Headers tab and make sure that SoapAction is not a header in there, or that it is set to Create like what you set in the body. This could be what is causing your bad request due to conflicting actions. Jan 21 at 15:50

1 Answer 1

0

Suggestion, trim it down -

A lot of the stuff in your query from the docs is "optional" and you can get rid of a lot of clutter in the soap header.

Here is what I use as a starting point when trying the same operation, as you can see the header is a lot shorter, while the CreateRequest is pretty much the same as yours :

<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>
        <fueloauth>{{accessToken}}</fueloauth>
     </soap:Header>
     <soap:Body>
          <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
               <Options/>
                    <Objects xsi:type="DataExtensionObject">
                         <PartnerKey xsi:nil="true"/>
                         <ObjectID xsi:nil="true"/>
                         <CustomerKey>f4a57fb4-9e68-49e9-8c7f-xxxxxxxxxx</CustomerKey>
                         <Properties>
                            <Property>
                                <Name>Something</Name>
                                <Value>myValue</Value>
                            </Property>
                    </Properties>
                 </Objects>
        </CreateRequest>
    </soap:Body>
</soap:Envelope>

Next of course verify your headers are correct. I have a suspicion that moving the SOAPaction to the actual request header, and out of the soap:header portion of the payload is the relevant change.

Content-Type: text/xml;charset=UTF-8
SOAPAction: "Create"
3
  • As a note, You can use it in the soap envelope header. I personally prefer that so I can make all the changes in one place instead of having to also edit headers. Jan 21 at 15:51
  • 1
    different habits I guess, I actually prefer it separately so I can always use the same soap envelope scaffolding for creates, retrieves etc. Jan 21 at 15:54
  • 1
    lol yeah and I like it in so I can duplicate it and change it to update or retrieve, etc. all in the envelope. Diff'rent strokes for Diff'rent folks. Jan 21 at 15:56

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.