You need to sign in to do that
Don't have an account?
Adding an attachment to an opportunity using SOAP message
Hi,
I am trying to add an attachment to an opportunity using a SOAP message. Below is the soap message :
I get the following response :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>sf:INVALID_TYPE</faultcode>
<faultstring>INVALID_TYPE: Must send a concrete entity type.</faultstring>
<detail>
<sf:InvalidSObjectFault xsi:type="sf:InvalidSObjectFault">
<sf:exceptionCode>INVALID_TYPE</sf:exceptionCode>
<sf:exceptionMessage>Must send a concrete entity type.</sf:exceptionMessage>
<sf:row>-1</sf:row>
<sf:column>-1</sf:column>
</sf:InvalidSObjectFault>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
The doc is an MS Word doc. Any ideas what I am doing wrong ? I am able to run queries no problem.
Thanks,
Prof
Thanks Simon,
That did the trick .... for the record the correct syntax is ...
All Answers
I believe "Name" and "Body" need to within the sObject definition, and you may need type as an attribute. See the sample SOAP create message:
http://wiki.developerforce.com/index.php/PartnerCreate
Hi
I put Name and Body in but still get the same message. Where do i add Type as an attribute, and what should it be ?
Thanks
prof
Oops, sorry, just saw where type should go.
Was the B tag in your SOAP type tag or was that just a message board format?
It's also possible the SOAP API is being nitpicky about the namespacing.
Nope, was in there because it was in the exapmple you referred me to. I took it out and still doesn't work, and gives the same error :(
Huh, so it was :) Pretty certain we don't need the bold tags in there, think that's a formatting error on the example...
So I'd check the namespacing ... but let me see if I can hunt down a specific attachment example. Know it's possible, but I don't have the code that I worked with laying around before.
What language are you using?
I am using Visual C++ 6 and have put together some classes to talk to Salesforce.
And is this partner or enterprise?
Enterprise
Ah, then I may have pointed you in the wrong direction. I think Enterprise uses the type attribute like you had before:
http://www.salesforce.com/us/developer/resources/soap/sforce60/sforce_API_messages_update.html
So perhaps the right combination is using the type attribute with the Name and Body included in the sObjects element?
I'll continue to poke around and see if I can find a specific attachment example.
You can find a list of SOAP calls at http://wiki.developerforce.com/index.php/Sample_SOAP_Messages
To create an attachment, you would use something like:
I get :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Client</faultcode>
<faultstring>The prefix "xsi" for attribute "xsi:type" associated with an element type "urn:sObjects" is not bound.</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
If I remove the xsi: from the sObjects attribute I get the same error as before, i.e.:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>sf:INVALID_TYPE</faultcode>
<faultstring>INVALID_TYPE: Must send a concrete entity type.</faultstring>
<detail>
<sf:InvalidSObjectFault xsi:type="sf:InvalidSObjectFault">
<sf:exceptionCode>INVALID_TYPE</sf:exceptionCode>
<sf:exceptionMessage>Must send a concrete entity type.</sf:exceptionMessage>
<sf:row>-1</sf:row>
<sf:column>-1</sf:column>
</sf:InvalidSObjectFault>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
For the enterprise API, you need to send the xsi:type attribute, and that will require you to declare the namespace binding for the xsi prefix (this is the first error message you got) e.g. add an xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" attribute to your Envelope element. (see the response xml for an example)
Thanks Simon,
That did the trick .... for the record the correct syntax is ...