创建复合包络时导致“错误调用CreateEnvelope - TAB_REFERS_TO_MISSING_DOCUMENT”错误的原因是什么?

时间:2016-05-13 00:11:21

标签: docusignapi

我有以下代码,应该发送一个包含多个模板的信封进行签名:

public void SendEvelope(List<string> templateIds)
{
    var envelope = new EnvelopeDefinition { EmailSubject = "Please sign this", Status = "created", CompositeTemplates = new List<CompositeTemplate>() };
    var ct = new CompositeTemplate { ServerTemplates = new List<ServerTemplate>(), InlineTemplates = new List<InlineTemplate>() };
    foreach (var templateId in templateIds)
    {
        var template = _templatesApi.Get(AccountId, templateId);
        if (template == null) continue;
        ct.ServerTemplates.Add(new ServerTemplate { TemplateId = templateId, Sequence = "1" });
        var it = new InlineTemplate
        {
            Sequence = "1",
            Recipients = new Recipients { Signers = new List<Signer>() }
        };
        var signer = new Signer
        {
            Name = "John Doe",
            Email = "me@here.com",
            RoleName = "Client",
            RecipientId = "1"
        };
        it.Recipients.Signers.Add(signer);
        ct.InlineTemplates.Add(it);
        envelope.CompositeTemplates.Add(ct);
    }
    _envelopesApi.CreateEnvelope(AccountId, envelope);
}

代码似乎正常工作,直到它到达CreateEnvelope命令,此时它崩溃并出现以下错误:

调用CreateEnvelope时出错:{“errorCode”:  “TAB_REFERS_TO_MISSING_DOCUMENT”,“message”:“DocumentId中指定的  tab元素不引用此信封中的文档。标签是指  不存在的DocumentId 54017690。“}

我没有在通话中指定任何标签或文档,而且我添加到信封的每个模板都存在,因为它们是从API一次一个地提取的。那么这里的问题是什么?我错过了什么?

编辑:

这是完整的堆栈跟踪:

DocuSign.eSign.Client.ApiException: Error calling CreateEnvelope: {
"errorCode": "TAB_REFERS_TO_MISSING_DOCUMENT",
"message": "The DocumentId specified in the tab element does not refer to a document in this envelope. Tab refers to DocumentId 54017690 which is not present."
}
at DocuSign.eSign.Api.EnvelopesApi.CreateEnvelopeWithHttpInfo(String accountId, EnvelopeDefinition envelopeDefinition, CreateEnvelopeOptions options) in y:\Docusign\Github\DevCenter\SDKs\csharp\sdk\src\main\csharp\DocuSign\eSign\Api\EnvelopesApi.cs:line 2606
at DocuSign.eSign.Api.EnvelopesApi.CreateEnvelope(String accountId, EnvelopeDefinition envelopeDefinition, CreateEnvelopeOptions options) in y:\Docusign\Github\DevCenter\SDKs\csharp\sdk\src\main\csharp\DocuSign\eSign\Api\EnvelopesApi.cs:line 2532
at LeadDocket.Core.Services.DocuSignService.SendEvelope(List`1 templateIds, Int32 leadId, Settings settings) in C:\inetpub\Websites\LeadDocket\Source\LeadDocket.Core\Services\DocuSignService.cs:line 64
at LeadDocket.Website.Controllers.LeadsController.PickTemplates(PickTemplatesViewModel model) in C:\inetpub\Websites\LeadDocket\Source\LeadDocket.Website\Controllers\LeadsController.cs:line 638
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

编辑2:

以下是我在日志中的内容:

POST https://demo.docusign.net:7801/restapi/v2/accounts/1661307/envelopes
Content-Length: 2148
Content-Type: application/json
Accept: application/json
Host: demo.docusign.net
User-Agent: RestSharp/100.0.0.0
X-DocuSign-SDK: C#
X-DocuSign-Authentication: {"Username":"mmijuskovic@somedomain.com", "Password":"[omitted]", "IntegratorKey":"[omitted]"}
X-Forwarded-For: 157.182.105.1
X-SecurityProtocol-Version: TLSv1
X-SecurityProtocol-CipherSuite: ECDHE-RSA-AES256-CBC-SHA

{"compositeTemplates":[{"serverTemplates":[{"sequence":"1","templateId":"3639308e-778d-46bf-9f82-04834166a2a6"},{"sequence":"1","templateId":"50c95d3c-0d55-4dca-924c-73dbf1437b27"},{"sequence":"1","templateId":"98960d61-f3e5-4fda-958c-122b972eecdd"}],"inlineTemplates":[{"sequence":"1","recipients":{"signers":[{"name":"Heather M. Batz","email":"me@here.com","recipientId":"1","roleName":"Client"}]}},{"sequence":"1","recipients":{"signers":[{"name":"Heather M. Batz","email":"me@here.com","recipientId":"1","roleName":"Client"}]}},{"sequence":"1","recipients":{"signers":[{"name":"Heather M. Batz","email":"me@here.com","recipientId":"1","roleName":"Client"}]}}]},{"serverTemplates":[{"sequence":"1","templateId":"3639308e-778d-46bf-9f82-04834166a2a6"},{"sequence":"1","templateId":"50c95d3c-0d55-4dca-924c-73dbf1437b27"},{"sequence":"1","templateId":"98960d61-f3e5-4fda-958c-122b972eecdd"}],"inlineTemplates":[{"sequence":"1","recipients":{"signers":[{"name":"Heather M. Batz","email":"me@here.com","recipientId":"1","roleName":"Client"}]}},{"sequence":"1","recipients":{"signers":[{"name":"Heather M. Batz","email":"me@here.com","recipientId":"1","roleName":"Client"}]}},{"sequence":"1","recipients":{"signers":[{"name":"Heather M. Batz","email":"me@here.com","recipientId":"1","roleName":"Client"}]}}]},{"serverTemplates":[{"sequence":"1","templateId":"3639308e-778d-46bf-9f82-04834166a2a6"},{"sequence":"1","templateId":"50c95d3c-0d55-4dca-924c-73dbf1437b27"},{"sequence":"1","templateId":"98960d61-f3e5-4fda-958c-122b972eecdd"}],"inlineTemplates":[{"sequence":"1","recipients":{"signers":[{"name":"Heather M. Batz","email":"me@here.com","recipientId":"1","roleName":"Client"}]}},{"sequence":"1","recipients":{"signers":[{"name":"Heather M. Batz","email":"me@here.com","recipientId":"1","roleName":"Client"}]}},{"sequence":"1","recipients":{"signers":[{"name":"Heather M. Batz","email":"me@here.com","recipientId":"1","roleName":"Client"}]}}]}],"status":"sent","emailSubject":"Local Firm - Please sign this"}
400 BadRequest
Content-Type: application/json; charset=utf-8

{
  "errorCode": "TAB_REFERS_TO_MISSING_DOCUMENT",
  "message": "The DocumentId specified in the tab element does not refer to a document in this envelope. Tab refers to DocumentId 54017690 which is not present."
}

0 个答案:

没有答案