+ Start a Discussion
SFDC coderSFDC coder 

SOAP request for delete call

hi all,
i have created a soap delete request in soap ui tool to delete records in salesforce using External id rather than using the SFDC record id however i am getting the below mentioned response 
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Client</faultcode>
         <faultstring>Element {urn:enterprise.soap.sforce.com}sObjects invalid at this location</faultstring>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>

my delete soap request is 
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
   <soapenv:Header>
      
      <urn:SessionHeader>
         <urn:sessionId>XXXXXXXXXXXXXXXXXXXXXXXXXX</urn:sessionId>
      </urn:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
     <urn:delete>

        <urn:externalIDFieldName>Product_Id__c</urn:externalIDFieldName>

        <!--Zero or more repetitions:-->

         <urn:sObjects urn:type="Product__c">

          <Product_Id__c>456721</Product_Id__c>

         </urn:sObjects>

      </urn:delete>

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

Any help would be appreciated

thanks
Sumitkumar_ShingaviSumitkumar_Shingavi
Did you put the valid sessions Id just like last time. There might be case of Session Id is expired so get a new one like you did yeasterday and try it. I am sure it will work.

PS: if this answers your question then hit Like and mark it as solution!
SFDC coderSFDC coder
yes its valid..
since i don't want to disclose it here i have put XXXXX.Also the other calls are working with the same session id
 
Sumitkumar_ShingaviSumitkumar_Shingavi
It is saying "sObjects invalid at this location" so is there any Product__c record exist with that external Id value?
SFDC coderSFDC coder
thanks for your kind assistance.
Yes it does exist i searched it globally and i found one record
Sumitkumar_ShingaviSumitkumar_Shingavi
You might find the record for that but is it having "456721" value in Product_Id__c field on that record. Set debug logs with the user you got that session Id and check what it shows. I am sure there is something weird around data.
SFDC coderSFDC coder
yes it is see the below screen

User-added image
Sumitkumar_ShingaviSumitkumar_Shingavi
Hmmm!! My best guess is, sometimes SFDC don't like SOUP UI/Manupulated SOAP request formats. But once you generate stub classes in Java using wsdlTojava or other tools, you should be able to make an easy callout as you will get parametric functions in those classes generated and you don't need to worry about these request formats.

PS: if this answers your question then hit Like and mark it as solution!
amidstcloudamidstcloud
Hi Sumit

Could you please share a sample where we can use the external id of the Lookup object. Thanks.