【问题标题】:Unable to send attachment - Salesforce Docusign API无法发送附件 - Salesforce Docusign API
【发布时间】:2016-12-02 14:28:36
【问题描述】:

我正在尝试通过 Apex 和 Docusign“CreateAndSendEnvelope”API 在机会记录中发送附件(记录有一个附件)。

但我收到此错误“DocuSign EnvelopeId:Exception - System.CalloutException: Web service callout failed: WebService returned an SOAP Fault: An Error Occurred during anchor tag processing. Invalid document faultcode=soap:Client faultactor =https://demo.docusign.net/api/3.0/dsapi.asmx"

下面是使用的一段代码。

 // Render the contract
        System.debug('Rendering the contract');
        PageReference pageRef = new PageReference('/apex/RenderContract');
        pageRef.getParameters().put('id',contract.Id);

        //Blob pdfBlob = pageRef.getContent();     
        Attachment att = [SELECT Id, Name, Body, ContentType FROM Attachment WHERE Parentid = :contract.Id LIMIT 1];
        Blob pdfBlob = att.Body; 


        // Document
        DocuSignAPI.Document document = new DocuSignAPI.Document();
        document.ID = 1;
        document.pdfBytes = EncodingUtil.base64Encode(pdfBlob);
        document.Name = 'Contract';
        document.FileExtension = 'pdf';
        envelope.Documents = new DocuSignAPI.ArrayOfDocument();
        envelope.Documents.Document = new DocuSignAPI.Document[1];
        envelope.Documents.Document[0] = document;

        // Recipient
        System.debug('getting the contact');
        Contact contact = [SELECT email, FirstName, LastName 
            from Contact where id = :contract.CustomerSignedId];

        DocuSignAPI.Recipient recipient = new DocuSignAPI.Recipient();
        recipient.ID = 1;
        recipient.Type_x = 'Signer';
        recipient.RoutingOrder = 1;
        recipient.Email = contact.Email;
        recipient.UserName = contact.FirstName + ' ' + contact.LastName;

        // This setting seems required or you see the error:
        // "The string '' is not a valid Boolean value. 
        // at System.Xml.XmlConvert.ToBoolean(String s)" 
        recipient.RequireIDLookup = false;      

        envelope.Recipients = new DocuSignAPI.ArrayOfRecipient();
        envelope.Recipients.Recipient = new DocuSignAPI.Recipient[1];
        envelope.Recipients.Recipient[0] = recipient;

        // Tab
        DocuSignAPI.Tab tab1 = new DocuSignAPI.Tab();
        tab1.Type_x = 'SignHere';
        tab1.RecipientID = 1;
        tab1.DocumentID = 1;
        tab1.AnchorTabItem = new DocuSignAPI.AnchorTab();
        tab1.AnchorTabItem.AnchorTabString = 'By:';


        DocuSignAPI.Tab tab2 = new DocuSignAPI.Tab();
        tab2.Type_x = 'DateSigned';
        tab2.RecipientID = 1;
        tab2.DocumentID = 1;
        tab2.AnchorTabItem = new DocuSignAPI.AnchorTab();
        tab2.AnchorTabItem.AnchorTabString = 'Date Signed:';

        envelope.Tabs = new DocuSignAPI.ArrayOfTab();
        envelope.Tabs.Tab = new DocuSignAPI.Tab[2];
        envelope.Tabs.Tab[0] = tab1;        
        envelope.Tabs.Tab[1] = tab2;        

        System.debug('Calling the API');
        try {
            DocuSignAPI.EnvelopeStatus es 
            = dsApiSend.CreateAndSendEnvelope(envelope);
            envelopeId = es.EnvelopeID;
        } catch ( CalloutException e) {
            System.debug('Exception - ' + e );
            envelopeId = 'Exception - ' + e;
        }

任何想法如何克服这个错误?

谢谢。

【问题讨论】:

  • 您的 docusign 帐户在哪个服务器上(看起来像演示,但只是仔细检查)?您是什么时候开始看到这个错误的?
  • 它是演示服务器..我在一小时前看到了这个错误..最初我正在尝试这个链接中的代码:link.它在将整个记录呈现为 pdf 时效果很好.. .但现在我尝试只发送附件而不是整个记录..我开始收到这个错误..任何输入请..tnx

标签: salesforce docusignapi apex


【解决方案1】:

原始海报 (OP) 的评论是

它在将整个记录呈现为 pdf 时效果很好......但现在我尝试只发送附件而不是整个记录......我开始收到这个错误。

所以我的猜测是信封请求存在文档问题。

最佳调试方式:查看发送到 DocuSign 平台的内容。

试试beta API loggerregular logger。然后通过编辑您的问题将日志添加到您的问题中。

【讨论】:

  • 嗨,我已经下载了日志文件,可以看到 9 个文件创建的名称为 00_ok_Getusersignature、01_notfound_getuserprofileimage、02_OK_getaccountsettings、03_Ok_Getusersettings、04_OK_getusersignatures、05_Ok_Getuserprofile、06_Ok_ExecuteloggedApiBusinessLogic、07_Internal server error_请让我知道是否需要任何这些文件的日志信息以进一步检查。谢谢
  • 我自己解决了.. document.FileExtension = 'pdf';.. 实际上我正在传递 word 文档,所以我将 document.FileExtension = 'pdf' 更改为 'docx'。它工作正常..谢谢,...
【解决方案2】:

这个问题遇到了同样的错误。 " 处理锚标记时出错。无效文档 faultcode=soap:Client faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx"

您需要将锚标签字符串替换为需要签名的附加文档中给出的所需字符串。

替换:

tab1.AnchorTabItem.AnchorTabString = 'By:'; tab2.AnchorTabItem.AnchorTabString = '签名日期:';

收件人:

tab1.AnchorTabItem.AnchorTabString = '文档中的签名标签'; tab2.AnchorTabItem.AnchorTabString = '文档中的签名标签';

【讨论】:

    猜你喜欢
    • 2019-05-24
    • 1970-01-01
    • 1970-01-01
    • 2018-05-06
    • 1970-01-01
    • 2019-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多