0

After researching, it appears that the SalesForce REST API unfortunately doesn't have an equivalent allowSave option for overriding duplicates that the SOAP API has. I'm writing a Python client that interfaces with SalesForce and I want to send a request with WSDL/SOAP that allows me to save the duplicates. I've got something in Postman, but not sure what I need in the body of the request and I don't want to have to download and install a SOAP library for this workaround. I tried googling but couldn't find anything. What should the body of the request look like?

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:urn1="urn:sobject.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Header>
    <urn:DuplicateRuleHeader>
      <urn:allowSave>1</urn:allowSave>
      <urn:runAsCurrentUser>0</urn:runAsCurrentUser>
    </urn:DuplicateRuleHeader>
    <urn:SessionHeader>
      <urn:sessionId>[OAuth token here]</urn:sessionId>
    </urn:SessionHeader>
  </soapenv:Header>
  <soapenv:Body>
    [What goes here to update an Account?]
  </soapenv:Body>
</soapenv:Envelope>

Not sure what needs to go in <soapenv:Body> to update an Account? I want to update some fields, e.g.:

"BillingStreet"
"BillingCity"
"ShippingStreet"
"ShippingCity"
"ShippingState"

Edit:

I'm sending this and it's working but still giving me a duplicate error:

  <soapenv:Body>
    <urn:update>
        <urn:sObjects xsi:type="urn1:Account">
            <urn:Id>[Id is here]</urn:Id>
            <urn:BillingState>North Carolina</urn:BillingState>
        </urn:sObjects>
    </urn:update>
  </soapenv:Body>

SOAP Response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <updateResponse>
            <result>
                <errors>
                    <fields xsi:nil="true"/>
                    <message>You are creating a duplicate record. We recommend you use an existing record instead.</message>
                    <statusCode>UNKNOWN_EXCEPTION</statusCode>
                </errors>
                <id xsi:nil="true"/>
                <success>false</success>
            </result>
        </updateResponse>
    </soapenv:Body>
</soapenv:Envelope>

Your Answer

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

Browse other questions tagged or ask your own question.