0

HAVE A SMALL REQUIREMENT

am trying to create a custom object using salesforce rest api ..here is my code

req=new Httprequest();

req.setEndpoint('https://ap1.salesforce.com/services/Soap/u/22.0/xxxxx')
string b ='

    <?xml version="1.0" encoding="UTF-8"?>'+
    '<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">'+
        '<deploymentStatus>Deployed</deploymentStatus>'+
        '<description>just a test object with one field for eclipse ide testing</description>'+
        '<fields>'+
            '<fullName>Comments__c</fullName>'+
            '<description>add your comments about this object here</description>'+
            '<inlineHelpText>This field contains comments made about this object</inlineHelpText>'+
            '<label>Comments</label>'+
            '<length>32000</length>'+
            '<type>LongTextArea</type>'+
            '<visibleLines>30</visibleLines>'+
        '</fields>'+
        '<label>MyFirstObject</label>'+
        '<nameField>'+
            '<label>MyFirstObject Name</label>'+
            '<type>Text</type>'+
        '</nameField>'+
        '<pluralLabel>MyFirstObjects</pluralLabel>'+
        '<sharingModel>ReadWrite</sharingModel>'+
    '</CustomObject>';


req.setHeader('Authorization','OAuth '+SESSION_ID);

req.setMethod('POST');
req.setHeader('Content-Type', 'text/xml;charset=UTF-8');

req.setHeader('SOAPAction', '""');

req.setbody(b);
p =new Http();

res=new Httpresponse();

res=p.send(req) ;

here is my error message

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <soapenv:Fault>
            <faultcode>soapenv:VersionMismatch</faultcode>
            <faultstring>The SOAP request must use SOAP 1.1, did not recieve a SOAP 1.1 Envelope as the document root</faultstring>
        </soapenv:Fault>
    </soapenv:Body>
</soapenv:Envelope>
5
  • Which wsdl are you using? enterprise or partner? Nov 27, 2013 at 14:28
  • Am not using any wsdl ,,am just sending it through rest with soap Header ..
    – Vineeth
    Nov 27, 2013 at 14:32
  • you may not be using wsdl to create message BUT the SOAP message must adhere to one of the two wsdls? Nov 27, 2013 at 14:34
  • great comment by @sfdcfox, follow that post & get all doubts clarified. Nov 27, 2013 at 14:35
  • Possibily missing SOAP envelop. Nov 27, 2013 at 15:58

0

Browse other questions tagged .