您确定的收件人不是指定信封的有效收件人 [英] The recipient you have identified is not a valid recipient of the specified envelope

查看:103
本文介绍了您确定的收件人不是指定信封的有效收件人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下代码,我可以从我的帐户中读取模板并发送包含该模板的电子邮件。

With the following code I am able to read the template from my account and send an email with that template is working.

EnvelopesApi envelopesApi1 = createEnvelopesApi(basePath,
    prop.getProperty("authenticationToken"));
EnvelopeDefinition envelope1 = makeEnvelope(signerEmail, signerName);
EnvelopeSummary result = envelopesApi1.createEnvelope(accountId, envelope1);

//   session.setEnvelopeId(result.getEnvelopeId());
DoneExample.createDefault("Cusotm title")
    .withJsonObject(result)
    .withMessage("The envelope has been created and sent!<br/>Envelope ID "
        + result.getEnvelopeId() + ".")
    .addToModel(model);

但是我的应用程序是嵌入式应用程序,因此需要在应用程序上进行批准,因此我尝试将其集成到我的嵌入式应用程序。但是我遇到了错误。我的代码如下。

But my application is embedded application, so the approval needs to be done over application Hence I have tried to integrate the same in my embedded application.But I am getting error. My code is below.

// Next, create the top level envelope definition and populate it.
EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();
envelopeDefinition.setEmailSubject("Please sign this document!!");
envelopeDefinition.setEmailBlurb("this is the custom mail content");
             
//envelopeDefinition.setDocuments(Arrays.asList(document));
envelopeDefinition.setTemplateId("6fcd32d8-91f6-4f4f-90f8-8b54eb71bfb8");
envelopeDefinition.setTemplateRoles(Arrays.asList(signer1));
// Add the recipient to the envelope object
Recipients recipients = new Recipients();
//recipients.setSigners(Arrays.asList(signer));
//envelopeDefinition.setRecipients(recipients);
envelopeDefinition.setStatus("sent");
// requests that the envelope be created and sent.
             
            
// Step 2. Call DocuSign to create and send the envelope
ApiClient apiClient = new ApiClient(basePath);
apiClient.setAccessToken(accessToken, tokenExpirationSeconds);
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
EnvelopeSummary results = envelopesApi.createEnvelope(accountId, envelopeDefinition);
String envelopeId = results.getEnvelopeId();

// Step 3. The envelope has been created.
//         Request a Recipient View URL (the Signing Ceremony URL)
RecipientViewRequest viewRequest = new RecipientViewRequest();
// Set the url where you want the recipient to go once they are done signing
// should typically be a callback route somewhere in your app.
viewRequest.setReturnUrl(baseUrl + "/ds-return");
viewRequest.setAuthenticationMethod(authenticationMethod);
viewRequest.setEmail(signerEmail);
viewRequest.setUserName(signerName);
viewRequest.setClientUserId(clientUserId);
// call the CreateRecipientView API
ViewUrl results1 = envelopesApi.createRecipientView(accountId, envelopeId, viewRequest);

// Step 4. The Recipient View URL (the Signing Ceremony URL) has been received.
//         The user's browser will be redirected to it.
String redirectUrl = results1.getUrl();

redirect = new RedirectView(redirectUrl);
redirect.setExposeModelAttributes(false);
} catch (IOException ex) {
    ex.printStackTrace();
} finally {
    if (input != null) {
        try {
            input.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
    }
}
return redirect;

}

此处出现以下错误。

com.docusign.esign.client.ApiException: 
   Error while requesting server, received a non successful 
   HTTP code 400 with response Body: 
   '{"errorCode":"UNKNOWN_ENVELOPE_RECIPIENT",
     "message":"The recipient you have identified is not a valid
         recipient of the specified envelope."}'

at com.docusign.esign.client.ApiClient.invokeAPI(ApiClient.java:1177) 
   ~[docusign-esign-java-3.2.0.jar:na]
at com.docusign.esign.api.EnvelopesApi.createRecipientView(EnvelopesApi.java:1262) 
   ~[docusign-esign-java-3.2.0.jar:na]
....


推荐答案

有两种方法可以解决此问题,一种是我下面的替代方法方式,第二个是Larry在评论中建议的,只是在发送信封时将clientUserId添加到签名者收件人中。

There are two ways to solve this problem, one is my below alternate way and the second one is as Larry suggested in the comment just add the clientUserId to the signer recipient when you send the envelope.

对于嵌入式符号,我们需要使用 CompositeTemplate

For embedded sign we need to go for CompositeTemplate

private EnvelopeDefinition makeEnvelope(String signerEmail, String signerName, String clientUserId, WorkArguments args) throws IOException {
            CarbonCopy cc1 = new CarbonCopy();
            cc1.setEmail("mail");
            cc1.setName("name");
            cc1.setRoleName(EnvelopeHelpers.CC_ROLE_NAME);
            cc1.setRecipientId("2");
    
            // create a composite template for the server template
            CompositeTemplate compTemplate1 = new CompositeTemplate();
            compTemplate1.setCompositeTemplateId("1");
            ServerTemplate serverTemplates = new ServerTemplate();
            serverTemplates.setSequence("1");
            serverTemplates.setTemplateId("dafgs345-546sdf4-3546sdfqew");
            compTemplate1.setServerTemplates(Arrays.asList(serverTemplates));
    
            // Add the roles via an inlineTemplate object
            InlineTemplate inlineTemplate = new InlineTemplate();
            inlineTemplate.setSequence("1");
            inlineTemplate.setRecipients(EnvelopeHelpers.createRecipients(createSigner(signerEmail,signerName,clientUserId), cc1));
            compTemplate1.setInlineTemplates(Arrays.asList(inlineTemplate));
    
            // The signer recipient for the added document with a tab definition
            Tabs signer1Tabs = EnvelopeHelpers.createSingleSignerTab("**signature_1**", ANCHOR_OFFSET_Y, ANCHOR_OFFSET_X);
            signer1Tabs.textTabs(Arrays.asList(
                    createText("text", "453", "110","Customized data"),
                    createText("numbersOnly", "453", "130", "147896")));
            Signer signer1AddedDoc = createSigner(signerEmail, signerName,clientUserId);
            signer1AddedDoc.setAccessCode("12345");
            signer1AddedDoc.setTabs(signer1Tabs);
    
            // Create the HTML document
            byte[] htmlDoc = EnvelopeHelpers.createHtmlFromTemplateFile(HTML_DOCUMENT_FILE_NAME, "args", args);
    
            // Create a composite template for the added document and add the recipients via an inlineTemplate
            CompositeTemplate compTemplate2 = new CompositeTemplate();
            compTemplate2.setCompositeTemplateId("2");
            InlineTemplate inlineTemplate2 = new InlineTemplate();
            inlineTemplate2.setSequence("2");
            inlineTemplate2.setRecipients(EnvelopeHelpers.createRecipients(signer1AddedDoc, cc1));
            compTemplate2.setInlineTemplates(Arrays.asList(inlineTemplate2));
            compTemplate2.setDocument(EnvelopeHelpers.createDocument(htmlDoc, HTML_DOCUMENT_NAME,
                    DocumentType.HTML.getDefaultFileExtention(), "1"));
    
            EnvelopeDefinition env = new EnvelopeDefinition();
            env.setStatus(EnvelopeHelpers.ENVELOPE_STATUS_SENT);
            env.setCompositeTemplates(Arrays.asList(compTemplate1, compTemplate2));
            return env;
}

然后我们可以调用api

and then we can call the api

            EnvelopeDefinition envelope = makeEnvelope(signerEmail, signerName, clientUserId, args);

            EnvelopeSummary envelopResults = envelopesApi2.createEnvelope(accountId, envelope);
            RecipientViewRequest viewRequest1 = makeRecipientViewRequest(args);
            ViewUrl viewUrl = envelopesApi2.createRecipientView(accountId, envelopResults.getEnvelopeId(), viewRequest1);
            return new RedirectView(viewUrl.getUrl());

这篇关于您确定的收件人不是指定信封的有效收件人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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