2

I have a Data Extension on Sales Force. The External KEY is: 841F2F2C-6D3A-40D3-9F03-53E7CF42CE45.

I'm trying to send a XML request as specified in the documentation:

Sales Force Documentation

Here is what I'm sending:

<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>
        <wsse:UsernameToken> 
            <wsse:Username>my_user_name</wsse:Username>
            <wsse:Password>my_pass_word</wsse:Password>     
        </wsse:UsernameToken>
    </wsse:Security>
</soap:Header>
<soap:Body>
    <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <Objects xsi:type="DataExtensionObject">
            <PartnerKey xsi:nil="true"/>
           <ObjectID xsi:nil="true"/>
           <CustomerKey>841F2F2C-6D3A-40D3-9F03-53E7CF42CE45</CustomerKey>
            <Properties>
                <Property>
                    <Name>EmailAddress</Name>
                    <Value>ruipedromachado@hotmail.com</Value>
                </Property>
            </Properties>
        </Objects>
    </CreateRequest>
</soap:Body>

...and the reply is that it can't find the KEY:

<soap:Envelope><soap:Header>
  <wsse:Security>
     <wsu:Timestamp wsu:Id="Timestamp-c0fab4b9-8ad7-42c5-b67c-82acf9bbaa81">
        <wsu:Created>2017-10-20T11:40:18Z</wsu:Created>
        <wsu:Expires>2017-10-20T11:45:18Z</wsu:Expires>
     </wsu:Timestamp>
  </wsse:Security></soap:Header><soap:Body>
  <CreateResponse xmlns="http://exacttarget.com/wsdl/partnerAPI">
     <Results xsi:type="DataExtensionCreateResult">
        <StatusCode>Error</StatusCode>
        <StatusMessage>Unable to retrieve Data Extension. Unable to locate Data Extension for CustomObjectKey: 841F2F2C-6D3A-40D3-9F03-53E7CF42CE45.</StatusMessage>
        <OrdinalID>0</OrdinalID>
        <ErrorCode>2</ErrorCode>
        <NewID>0</NewID>
        <Object xsi:type="DataExtensionObject">
           <PartnerKey xsi:nil="true"/>
           <ObjectID xsi:nil="true"/>
           <CustomerKey>841F2F2C-6D3A-40D3-9F03-53E7CF42CE45</CustomerKey>
           <Properties>
              <Property>
                 <Name>EmailAddress</Name>
                 <Value>ruipedromachado@hotmail.com</Value>
              </Property>
           </Properties>
        </Object>
        <ErrorMessage>Unable to retrieve Data Extension. Unable to locate Data Extension for CustomObjectKey: 841F2F2C-6D3A-40D3-9F03-53E7CF42CE45.</ErrorMessage>
     </Results>
     <RequestID>647d216e-91c6-4dab-888a-dc8f73e66d92</RequestID>
     <OverallStatus>Error</OverallStatus>
  </CreateResponse>

Any ideas what am missing?

Thanks

  • 2
    Please clarify: Are you looking to retrieve a data extension, or to create a new row inside an existing data extension? – Gortonington Oct 20 '17 at 12:24
  • 1
    ^^ There are several SOAP API objects relating to Data Extensions. We can help better if we know specifically what you're trying to retrieve. – Adam Spriggs Oct 20 '17 at 13:24
  • 1
    If you're trying to retrieve rows from a Data Extension, this question has already been answered: salesforce.stackexchange.com/a/152415/5202 – Adam Spriggs Oct 20 '17 at 13:30
0

If it contains more than 1 lakh records in Data Extension , you have to retrieve 2,500 records each time by using Continue Request in Soap api,for this scenario better use FTP for exporting importing the data into data Extension

Data Extension data Retrieve request

Here is the Retrieving data for Data Extension

     <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:par="http://exacttarget.com/wsdl/partnerAPI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <soapenv:Header>
          <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
             <UsernameToken>
                <Username>xxxxxx</Username>
                <Password>xxxxxx</Password>
             </UsernameToken>
          </Security>
       </soapenv:Header>
      <soapenv:Body>
    <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
          <RetrieveRequest>
      <ObjectType>DataExtensionObject[External key]</ObjectType>
            <Properties>EmailAddress</Properties>
            <Properties>FirstName</Properties>
           <Properties>LastName</Properties>
           <Properties>PrimaryKey</Properties>

<Options>
              <BatchSize>26902</BatchSize>
            </Options>
          </RetrieveRequest>
        </RetrieveRequestMsg>

    </soapenv:Body>
    </soapenv:Envelope>

Data Extension for data inserting Request

 <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 wsu:Id="SecurityToken-6421ac0b-a454-42a3-99f7-a77ace024446"> 
                                                          <wsse:Username>XXXXX</wsse:Username>
                        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">XXXXX</wsse:Password>     
                   </wsse:UsernameToken>
              </wsse:Security>
         </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>Definition_Key</CustomerKey>
                            <Properties>
                                <Property>
                                       <Name>EmailAddress</Name>
                                       <Value>xxxxxx</Value>
                            </Property>
                            <Property>
                            <Name>FirstName</Name>
                               <Value>xxxx</Value>
                            </Property>
                            <Property>
                               <Name>LastName</Name>
                               <Value>Doe</Value>
                            </Property>
                            <Property>
                               <Name>PrimaryKey</Name>
                               <Value>PrimaryKey</Value>
                            </Property>
                        </Properties>

                        <Properties>
                            <Property>
                                <Name>EmailAddress</Name>
                                   <Value>xxxxxx</Value>
                            </Property>
                            <Property>
                                <Name>FirstName</Name>
                                  <Value>xxxx</Value>
                            </Property>
                            <Property>
                               <Name>LastName</Name>
                                  <Value>Doe</Value>
                            </Property>
                            <Property>
                               <Name>PrimaryKey</Name>
                                 <Value>PrimaryKey</Value>
                            </Property>
                        </Properties>
                     </Objects>
            </CreateRequest>
        </soap:Body>
    </soap:Envelope>

This is the sample code inserting two data into data Extension, you can create all data into data extension

0

ok, got it working.

needed to add the business unit, so:

....

<Objects xsi:type="DataExtensionObject">
                <Client>
                       <ID>business_unit_id</ID>
                  </Client>
                    <PartnerKey xsi:nil="true"/>

....

  • i'm new to MC and DE. I want to fetch the dataextensions by using to write java code using Spring boot. But no idea where to start and how to setup the project. Can you help me on this. – RKCY Feb 5 at 16:43
  • Hello mate, I would suggest reading thru the documentation. developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/… SFMC exposes to services SOAP and REST for you to consume. – rpcm Feb 6 at 17:30

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.