私はSalesForceの「ビートボックス」ライブラリを使用しています(http://code.google.com/p/salesforce-beatbox/source/browse/trunk/src/beatbox/_beatbox.py)
例外1:leadIdを送信するだけで、「INVALID_CROSS_REFERENCE_KEY:有効なleadIdが必要です」という例外が発生します。
これは、有効なleadIdを使用していないことを示していますが、事前にリードを取得し、SalesForce自体からleadIdを取得したため、有効なleadIdであることを誓います。
例外2:convertedStatusパラメーターとdoNotCreateOpportunityパラメーターのコメントを解除すると、「soapenv:Client fault:Element {urn:partner.soap.sforce.com} doNotCreateOpportunity invalidatthislocation」という例外が発生します。
これは、SalesForceAPIにパラメーターを渡す方法に問題があることを示しています。それは私には正しいように見えます。
これらを解決する方法について何かアイデアはありますか?
def convertLead(self, leadIds, convertedStatus, doNotCreateOpportunity=False):
return ConvertLeadRequest(self.__serverUrl, self.sessionId, leadIds, convertedStatus, doNotCreateOpportunity).post(self.__conn)
class ConvertLeadRequest(AuthenticatedRequest):
"""
Converts a Lead to an Account. See also:
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_convertlead.htm
"""
def __init__(self, serverUrl, sessionId, leadIds, convertedStatus, doNotCreateOpportunity=False):
AuthenticatedRequest.__init__(self, serverUrl, sessionId, "convertLead")
self.__convertedStatus = convertedStatus
self.__leadIds = leadIds;
self.__doNotCreateOpportunity = doNotCreateOpportunity
def writeBody(self, s):
#s.writeStringElement(_partnerNs, "convertedStatus", self.__convertedStatus)
#s.writeStringElement(_partnerNs, "doNotCreateOpportunity", self.__doNotCreateOpportunity)
s.writeStringElement(_partnerNs, "leadId", self.__leadIds)
編集:
さて、私が次の要求をするとき:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:p="urn:partner.soap.sforce.com" xmlns:m="http://soap.sforce.com/2006/04/metadata" xmlns:o="urn:sobject.partner.soap.sforce.com" xmlns:w="http://soap.sforce.com/2006/08/apex" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<s:Header>
<p:CallOptions>
<p:client>BeatBox/0.9</p:client>
</p:CallOptions>
<p:SessionHeader>
<p:sessionId>REDACTED</p:sessionId>
</p:SessionHeader>
</s:Header>
<s:Body>
<p:convertLead>
<p:convertedStatus>Cold Qualified</p:convertedStatus>
<p:doNotCreateOpportunity>False</p:doNotCreateOpportunity>
<p:leadId>00QC000000zAbLEMA0</p:leadId>
<p:overwriteLeadSource>False</p:overwriteLeadSource>
<p:sendNotificationEmail>False</p:sendNotificationEmail>
</p:convertLead>
</s:Body>
</s:Envelope>
それでも「変換されたステータスが無効です」という例外が発生します
<?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 {urn:partner.soap.sforce.com}convertedStatus invalid at this location</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>