【问题标题】:CreateEnvelopeFromTemplates - Guid should contain 32 digits with 4 dashesCreateEnvelopeFromTemplates - Guid 应包含 32 位数字和 4 个破折号
【发布时间】:2016-03-02 20:54:02
【问题描述】:

我正在尝试使用 CreateEnvelopeFromTemplates 方法从模板文档创建一个 DocuSign 信封,该方法在他们的 v3 SOAP API Web 服务中可用。这是从 asp.NET v4.0 网站实例化的。

在调用带有传入所需参数对象的方法时。我从 Web 服务收到异常,基本上告诉我模板 ID 不是有效的 GUID。

669393: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

Line 14889:        
Line 14890:        public DocuSignDSAPI.EnvelopeStatus CreateEnvelopeFromTemplates(DocuSignDSAPI.TemplateReference[] TemplateReferences, DocuSignDSAPI.Recipient[] Recipients, DocuSignDSAPI.EnvelopeInformation EnvelopeInformation, bool ActivateEnvelope) {
Line 14891:            return base.Channel.CreateEnvelopeFromTemplates(TemplateReferences, Recipients, EnvelopeInformation, ActivateEnvelope);
Line 14892:        }
Line 14893:

模板引用,一个guid。必须指定为针对 TemplateReference 对象的“模板”字符串属性。然后将其添加到 TemplateReferences 的动态数组中,该数组是 CreateEnvelopeFromTemplates 方法的输入参数之一。

实际模板 GUID:f37b4d64-54e3-4723-a6f1-a4120f0e9695

我正在使用我编写的以下函数构建我的模板引用对象,以尝试使功能可重用:

Private Function GetTemplateReference(ByVal TemplateID As String) As TemplateReference

    Dim templateReference As New TemplateReference
    Dim guidTemplateID As Guid

    With TemplateReference

        .TemplateLocation = TemplateLocationCode.Server

        If Guid.TryParse(TemplateID, guidTemplateID) Then
            .Template = guidTemplateID.ToString
        End If

    End With

    Return TemplateReference

End Function

TemplateID 是在 TemplateReferences 数组实例化时从 appSetting 配置值传入的...

templateReferences = New TemplateReference() {GetTemplateReference(ConfigurationManager.AppSettings("DocuSignTemplate_Reference"))}
            recipients = New Recipient() {AddRecipient("myself@work.email", "My Name")}

            envelopeInformation = CreateEnvelopeInformation()
            envelopeStatus = client.CreateEnvelopeFromTemplates(templateReferences, recipients, envelopeInformation, True)

正如您从我的 GetTemplateReference 函数中看到的那样,我还在将 GUID 设置回字符串之前对其进行解析,因此我知道它是有效的。模板在DocuSign端进行管理和存储,从而指定文档位置。

我指的是他们自己的文档: CreateEnvelopeFromTemplates

为什么哦,为什么该方法不喜欢我的模板 ID?我可以使用他们自己的代码示例成功地使用他们的 REST API 调用相同的方法。在最坏的情况下,我可以使用它,但宁愿与 Web 服务交互,因为我需要以 XML 或 JSON 格式构建所有相关请求。

如果有人能阐明这个问题,我将不胜感激。

感谢您花时间阅读我的问题!

【问题讨论】:

  • 你能发布你传递的数据的踪迹吗?看起来您可能缺少 AccountID 或其他一些 GUID

标签: asp.net vb.net docusignapi


【解决方案1】:

Andrew 可能会注意到 AccountId 提及 - 您是否在信封信息对象中设置了 AccountId?另外,您在 Github 上看到过 DocuSign SOAP SDK 吗?这有 5 个示例 SOAP 项目,包括一个 MS.NET 项目。 .NET 项目使用 C# 而不是 Visual Basic,但我仍然认为它会对您有所帮助。在此处查看 SOAP SDK:

https://github.com/docusign/DocuSign-eSignature-SDK

例如,这里是 CreateEnvelopeFromTemplates() 函数的测试函数:

    public void CreateEnvelopeFromTemplatesTest()
    {
        // Construct all the recipient information
        DocuSignWeb.Recipient[] recipients = HeartbeatTests.CreateOneSigner();
        DocuSignWeb.TemplateReferenceRoleAssignment[] finalRoleAssignments = new DocuSignWeb.TemplateReferenceRoleAssignment[1];
        finalRoleAssignments[0] = new DocuSignWeb.TemplateReferenceRoleAssignment();
        finalRoleAssignments[0].RoleName = recipients[0].RoleName;
        finalRoleAssignments[0].RecipientID = recipients[0].ID;

        // Use a server-side template -- you could make more than one of these
        DocuSignWeb.TemplateReference templateReference = new DocuSignWeb.TemplateReference();
        templateReference.TemplateLocation = DocuSignWeb.TemplateLocationCode.Server;
        // TODO: replace with template ID from your account
        templateReference.Template = "server template ID";
        templateReference.RoleAssignments = finalRoleAssignments;

        // Construct the envelope information
        DocuSignWeb.EnvelopeInformation envelopeInfo = new DocuSignWeb.EnvelopeInformation();
        envelopeInfo.AccountId = _accountId;
        envelopeInfo.Subject = "create envelope from templates test";
        envelopeInfo.EmailBlurb = "testing docusign creation services";

        // Create draft with all the template information
        DocuSignWeb.EnvelopeStatus status = _apiClient.CreateEnvelopeFromTemplates(new DocuSignWeb.TemplateReference[] { templateReference },
            recipients, envelopeInfo, false);

        // Confirm that the envelope has been assigned an ID
        Assert.IsNotNullOrEmpty(status.EnvelopeID);
        Console.WriteLine("Status for envelope {0} is {1}", status.EnvelopeID, status.Status);
    }

此代码调用 SDK 中我未包含的其他示例函数,但希望这有助于阐明您做错了什么...

【讨论】:

    【解决方案2】:

    当您没有设置字段 AccountId 时会出现此问题。可以从您的帐户中检索此字段。在 Docusign 的控制台中,转到 Preferences / API 并查看此处

    Where to find AccountID Guid in Docusign's Console

    使用 API 帐户 ID(GUID 格式)应该没问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多