随着Salesforce的API,有什么事情,有两个例外是什么意思? [英] With the SalesForce API, what do these two exceptions mean?

查看:375
本文介绍了随着Salesforce的API,有什么事情,有两个例外是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Salesforce的节奏口技库(的http://$c$c.google.com/p/salesforce-beatbox/source/browse/trunk/src/beatbox/_beatbox.py)

I am using the SalesForce "Beatbox" Library (http://code.google.com/p/salesforce-beatbox/source/browse/trunk/src/beatbox/_beatbox.py)

例外情况1:当我刚发leadId,我得到的异常INVALID_CROSS_REFERENCE_KEY:有效leadId是必需的

EXCEPTION 1: When I just send the leadId, I get the exception "INVALID_CROSS_REFERENCE_KEY: valid leadId is required"

这是说我没有使用有效的leadId,但我发誓这是一个有效的leadId,因为我做了一个检索铅事先并从Salesforce自己!

This is saying I'm not using a valid leadId, but I swear it's a valid leadId because I did a retrieve lead beforehand and took the leadId from SalesForce themselves!

例外2:
当我取消了convertedStatus和doNotCreateOpportunity参数,我得到的异常soapenv:客户端故障:元素{金塔:partner.soap.sforce.com} doNotCreateOpportunity在这个位置无效

EXCEPTION 2: When I uncomment the convertedStatus and doNotCreateOpportunity parameters, I get the exception "soapenv:Client fault: Element {urn:partner.soap.sforce.com}doNotCreateOpportunity invalid at this location"

这是说什么是错的,我传递参数给Salesforce的API的方式。它看起来正确的我虽然。

This is saying something is wrong with the way I'm passing the parameters to the SalesForce API. It looks correct to me though.

这是如何解决这些任何想法?

Any ideas on how to resolve these?

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)

编辑:

现在,当我提出以下要求:

Now, when I make the following request:

<?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>

我仍然得到异常转换身份是无效的

I still get the exception "converted status is invalid"

<?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>


推荐答案

的问题是,writeBody部未产生正确的结构。检查的WSDL表明convertLead呼叫期望采取这些结构0..N。 (异常#2是暗示这个)

The problem is that writeBody is not generating the correct structure. checking the WSDL shows that the convertLead call is expecting to take 0..n of these structures. (Exception #2 is the hint about this)

    <element name="convertLead">
        <complexType>
            <sequence>
                <element name="leadConverts" type="tns:LeadConvert" minOccurs="0" maxOccurs="unbounded"/>
            </sequence>
        </complexType>
    </element>

    <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>

所以你writeBody必须像

so your writeBody needs to be something like

def writeBody(self, s):
    s.startElement(_partnerNs, "leadConverts")
    s.writeElementString(_partnerNs, "convertedStatus", self.__convertedStatus)
    s.writeElementString(_partnerNs, "doNotCreateOpportunity", self.__doNotCreateOpportunity)
    s.writeElementString(_partnerNs, "leadId", self.__leadId)
    ...
    s.endElement()

如果你想要做批量线索转换,那么你就需要生成这种结构的多个实例你想要做的每根引线的转换。

If you want to do bulk lead convert, then you'll need to generate multiple instance of this structure for each lead conversion you want to do.

这篇关于随着Salesforce的API,有什么事情,有两个例外是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆