function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
cfdudecfdude 

ConvertLead call gives error "Element X invalid at this location", Enterprise SOAP 22.0

Hi, I'm using ColdFusion 9.01 and the Enterprise Soap API, version 22.0.  I'm trying to call the convertLead() method and I'm getting the following error.

 

Request sent:

 

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
        <urn:SessionHeader>
            <urn:sessionId>(sessionid removed for clarity)</urn:sessionId>
        </urn:SessionHeader>
    </soapenv:Header>
    <soapenv:Body>
        <urn:convertLead>
            <urn:leadConverts>
                <OPPORTUNITYNAME>Joe Blow - 30 Day Trial</OPPORTUNITYNAME>
                <SENDNOTIFICATIONEMAIL>1</SENDNOTIFICATIONEMAIL>
                <CONTACTID/>
                <DONOTCREATEOPPORTUNITY>false</DONOTCREATEOPPORTUNITY>
                <LEADID>00QE0000001z3XC</LEADID>
                <OWNERID>005ExxxxxxxXa7hIAC</OWNERID>
                <OVERWRITELEADSOURCE>1</OVERWRITELEADSOURCE>
                <CONVERTEDSTATUS>Qualified</CONVERTEDSTATUS>
                <ACCOUNTID/>
            </urn:leadConverts>
        </urn:convertLead>
    </soapenv:Body>
</soapenv:Envelope>

 

 

Response:

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Client</faultcode><faultstring>Element {}OPPORTUNITYNAME invalid at this location</faultstring></soapenv:Fault></soapenv:Body></soapenv:Envelope>

 

The thing is, if I rearrange the leadConverts elements it will always bark at whatever the first one is.  If i remove all but one, then it barks at the only remaining one.  Please help.  Thanks!

 



Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

XML is case sensitive, try using the correct case for the element names (you can see them in the WSDL.

 

          <complexType name="LeadConvert">
                <sequence>
                    <element name="accountId"              type="tns:ID" nillable="true"/>
                    <element name="contactId"              type="tns:ID" nillable="true"/>
                    <element name="convertedStatus"        type="xsd:string"/>
                    <element name="doNotCreateOpportunity" type="xsd:boolean"/>
                    <element name="leadId"                 type="tns:ID"/>
                    <element name="opportunityName"        type="xsd:string" nillable="true"/>
                    <element name="overwriteLeadSource"    type="xsd:boolean"/>
                    <element name="ownerId"                type="tns:ID"     nillable="true"/>
                    <element name="sendNotificationEmail"  type="xsd:boolean"/>
                </sequence>
            </complexType>

 

All Answers

SuperfellSuperfell

XML is case sensitive, try using the correct case for the element names (you can see them in the WSDL.

 

          <complexType name="LeadConvert">
                <sequence>
                    <element name="accountId"              type="tns:ID" nillable="true"/>
                    <element name="contactId"              type="tns:ID" nillable="true"/>
                    <element name="convertedStatus"        type="xsd:string"/>
                    <element name="doNotCreateOpportunity" type="xsd:boolean"/>
                    <element name="leadId"                 type="tns:ID"/>
                    <element name="opportunityName"        type="xsd:string" nillable="true"/>
                    <element name="overwriteLeadSource"    type="xsd:boolean"/>
                    <element name="ownerId"                type="tns:ID"     nillable="true"/>
                    <element name="sendNotificationEmail"  type="xsd:boolean"/>
                </sequence>
            </complexType>

 

This was selected as the best answer
cfdudecfdude

Simon, thanks!  That was the issue I was having.  Once I changed the element names to the right case and matched the wsdl definition it worked like a charm.