createRecipient 调用抛出 'No recipients specified' 错误
createRecipient call throwing 'No recipients specified' error
我正在努力更改签名者的角色类型。为此,我从信封中删除签名者,然后使用不同的 signingGroupId 将它们重新添加到信封中。
为此,我正在执行以下操作:
const newClientRole = new docusign.TemplateRole();
newClientRole.setName(signerName);
newClientRole.setEmail(signerEmail);
newClientRole.setRoleName(opts.clientUserId);
newClientRole.setClientUserId(opts.clientUserId);
newClientRole.setSigningGroupId(opts.contact.futureRoleGroup);
newClientRole.setDefaultRecipient(signerEmail);
newClientRole.setInPersonSignerName(signerName)
console.log('newClientRole', newClientRole);
envelopesApi.createRecipient(accountId, pair.envelopeId, newClientRole, (err, data, response) => {
if (err) {
return cb(err);
}
return cb(null, data);
})
但是,当我这样做时,我得到:
error:
{ [Error: cannot POST /restapi/v2/accounts/<MY ACOUNT ACCOUNT ID>/envelopes/0dbc5905-0aa2-4005-8455-ae50332dd803/recipients (400)]
status: 400,
text: '{\r\n "errorCode": "INVALID_REQUEST_PARAMETER",\r\n "message": "The request contained at least one invalid parameter. No recipients specified."\r\n}',
method: 'POST',
path: '/restapi/v2/accounts/<MY ACOUNT ACCOUNT ID>/envelopes/0dbc5905-0aa2-4005-8455-ae50332dd803/recipients' },
我不确定该怎么办,因为我明确指定了收件人。我担心我没有正确实例化 newClientRole,所以我将其注销,看起来还不错:
newClientRole TemplateRole {
email: '<OUR ACTUAL EMAIL>',
roleName: 'client1',
name: 'Edward Wu',
signingGroupId: 'signers',
inPersonSignerName: 'Edward Wu',
clientUserId: 'client1',
embeddedRecipientStartURL: null,
defaultRecipient: '<OUR ACTUAL EMAIL>',
accessCode: null,
routingOrder: null,
emailNotification: null,
tabs: null,
constructFromObject: [Function],
getEmail: [Function],
setEmail: [Function],
getRoleName: [Function],
setRoleName: [Function],
getName: [Function],
setName: [Function],
getSigningGroupId: [Function],
setSigningGroupId: [Function],
getInPersonSignerName: [Function],
setInPersonSignerName: [Function],
getClientUserId: [Function],
setClientUserId: [Function],
getEmbeddedRecipientStartURL: [Function],
setEmbeddedRecipientStartURL: [Function],
getDefaultRecipient: [Function],
setDefaultRecipient: [Function],
getAccessCode: [Function],
setAccessCode: [Function],
getRoutingOrder: [Function],
setRoutingOrder: [Function],
getEmailNotification: [Function],
setEmailNotification: [Function],
getTabs: [Function],
setTabs: [Function],
toJson: [Function] }
我在此处包含了完整的错误文本:https://gist.github.com/dzoba/e9e1619ae6924efb440e20535b210661
我还在 Docusign 管理员中打开了记录 API 呼叫,并看到请求(与收件人)通过那里。从 Docusign 下载的日志是这样说的:
https://gist.github.com/dzoba/e9bb9e8e2c3399d61291024559d41e9e
基于这样的 API logging info you posted, the reason for the error is that your request body is missing the (top-level) signers attribute -- an array that contains an object for each signer you want to add. So, in your scenario (adding a single signer), the request body should contain an EnvelopeRecipients 对象:
{
"signers": [
{
"email": "<OUR ACTUAL EMAIL>",
"roleName": "client1",
"name": "Edward Wu",
"signingGroupId": "signers",
"inPersonSignerName": "Edward Wu",
"clientUserId": "client1",
"embeddedRecipientStartURL": null,
"defaultRecipient": "<OUR ACTUAL EMAIL>",
"accessCode": null,
"routingOrder": null,
"emailNotification": null,
"tabs": null
}
]
}
DocuSign 正在返回 未指定收件人。 错误消息,因为它在 EnvelopeRecipients 对象的顶级属性(即 agents、carbonCopies、signers 等)——因为您的请求正文不包含任何这些顶级属性, DocuSign 无法将请求正文识别为包含任何收件人。
编辑#1
所以,现在我了解到您的情况是您想要将收件人从 "sign in-person" 更改为 "sign remotely via email"。为此,您必须从信封中删除原始收件人,然后将新收件人添加到信封中(正如您在下面的评论中指出的那样)。
向信封添加新收件人(签名者)的代码如下所示。请记住,默认情况下新收件人将没有选项卡——您必须为新收件人指定 any/all 选项卡(下面的示例代码指定单个 SignHere 选项卡)。
// add a recipient to sign the document
var signer = new docusign.Signer();
signer.setEmail(signerEmail);
signer.setName(signerName);
signer.setRecipientId('1');
// create a signHere tab somewhere on the document for the signer to sign
// default unit of measurement is pixels, can be mms, cms, inches also
var signHere = new docusign.SignHere();
signHere.setDocumentId('1');
signHere.setPageNumber('1');
signHere.setRecipientId('1');
signHere.setXPosition('100');
signHere.setYPosition('100');
// can have multiple tabs, so need to add to envelope as a single element list
var signHereTabs = [];
signHereTabs.push(signHere);
var tabs = new docusign.Tabs();
tabs.setSignHereTabs(signHereTabs);
signer.setTabs(tabs);
// add recipients (in this case a single signer) to the envelope
envDef.setRecipients(new docusign.Recipients());
envDef.getRecipients().setSigners([]);
envDef.getRecipients().getSigners().push(signer);
(此代码示例源自 here。)
我正在努力更改签名者的角色类型。为此,我从信封中删除签名者,然后使用不同的 signingGroupId 将它们重新添加到信封中。
为此,我正在执行以下操作:
const newClientRole = new docusign.TemplateRole();
newClientRole.setName(signerName);
newClientRole.setEmail(signerEmail);
newClientRole.setRoleName(opts.clientUserId);
newClientRole.setClientUserId(opts.clientUserId);
newClientRole.setSigningGroupId(opts.contact.futureRoleGroup);
newClientRole.setDefaultRecipient(signerEmail);
newClientRole.setInPersonSignerName(signerName)
console.log('newClientRole', newClientRole);
envelopesApi.createRecipient(accountId, pair.envelopeId, newClientRole, (err, data, response) => {
if (err) {
return cb(err);
}
return cb(null, data);
})
但是,当我这样做时,我得到:
error:
{ [Error: cannot POST /restapi/v2/accounts/<MY ACOUNT ACCOUNT ID>/envelopes/0dbc5905-0aa2-4005-8455-ae50332dd803/recipients (400)]
status: 400,
text: '{\r\n "errorCode": "INVALID_REQUEST_PARAMETER",\r\n "message": "The request contained at least one invalid parameter. No recipients specified."\r\n}',
method: 'POST',
path: '/restapi/v2/accounts/<MY ACOUNT ACCOUNT ID>/envelopes/0dbc5905-0aa2-4005-8455-ae50332dd803/recipients' },
我不确定该怎么办,因为我明确指定了收件人。我担心我没有正确实例化 newClientRole,所以我将其注销,看起来还不错:
newClientRole TemplateRole {
email: '<OUR ACTUAL EMAIL>',
roleName: 'client1',
name: 'Edward Wu',
signingGroupId: 'signers',
inPersonSignerName: 'Edward Wu',
clientUserId: 'client1',
embeddedRecipientStartURL: null,
defaultRecipient: '<OUR ACTUAL EMAIL>',
accessCode: null,
routingOrder: null,
emailNotification: null,
tabs: null,
constructFromObject: [Function],
getEmail: [Function],
setEmail: [Function],
getRoleName: [Function],
setRoleName: [Function],
getName: [Function],
setName: [Function],
getSigningGroupId: [Function],
setSigningGroupId: [Function],
getInPersonSignerName: [Function],
setInPersonSignerName: [Function],
getClientUserId: [Function],
setClientUserId: [Function],
getEmbeddedRecipientStartURL: [Function],
setEmbeddedRecipientStartURL: [Function],
getDefaultRecipient: [Function],
setDefaultRecipient: [Function],
getAccessCode: [Function],
setAccessCode: [Function],
getRoutingOrder: [Function],
setRoutingOrder: [Function],
getEmailNotification: [Function],
setEmailNotification: [Function],
getTabs: [Function],
setTabs: [Function],
toJson: [Function] }
我在此处包含了完整的错误文本:https://gist.github.com/dzoba/e9e1619ae6924efb440e20535b210661
我还在 Docusign 管理员中打开了记录 API 呼叫,并看到请求(与收件人)通过那里。从 Docusign 下载的日志是这样说的:
https://gist.github.com/dzoba/e9bb9e8e2c3399d61291024559d41e9e
基于这样的 API logging info you posted, the reason for the error is that your request body is missing the (top-level) signers attribute -- an array that contains an object for each signer you want to add. So, in your scenario (adding a single signer), the request body should contain an EnvelopeRecipients 对象:
{
"signers": [
{
"email": "<OUR ACTUAL EMAIL>",
"roleName": "client1",
"name": "Edward Wu",
"signingGroupId": "signers",
"inPersonSignerName": "Edward Wu",
"clientUserId": "client1",
"embeddedRecipientStartURL": null,
"defaultRecipient": "<OUR ACTUAL EMAIL>",
"accessCode": null,
"routingOrder": null,
"emailNotification": null,
"tabs": null
}
]
}
DocuSign 正在返回 未指定收件人。 错误消息,因为它在 EnvelopeRecipients 对象的顶级属性(即 agents、carbonCopies、signers 等)——因为您的请求正文不包含任何这些顶级属性, DocuSign 无法将请求正文识别为包含任何收件人。
编辑#1
所以,现在我了解到您的情况是您想要将收件人从 "sign in-person" 更改为 "sign remotely via email"。为此,您必须从信封中删除原始收件人,然后将新收件人添加到信封中(正如您在下面的评论中指出的那样)。
向信封添加新收件人(签名者)的代码如下所示。请记住,默认情况下新收件人将没有选项卡——您必须为新收件人指定 any/all 选项卡(下面的示例代码指定单个 SignHere 选项卡)。
// add a recipient to sign the document
var signer = new docusign.Signer();
signer.setEmail(signerEmail);
signer.setName(signerName);
signer.setRecipientId('1');
// create a signHere tab somewhere on the document for the signer to sign
// default unit of measurement is pixels, can be mms, cms, inches also
var signHere = new docusign.SignHere();
signHere.setDocumentId('1');
signHere.setPageNumber('1');
signHere.setRecipientId('1');
signHere.setXPosition('100');
signHere.setYPosition('100');
// can have multiple tabs, so need to add to envelope as a single element list
var signHereTabs = [];
signHereTabs.push(signHere);
var tabs = new docusign.Tabs();
tabs.setSignHereTabs(signHereTabs);
signer.setTabs(tabs);
// add recipients (in this case a single signer) to the envelope
envDef.setRecipients(new docusign.Recipients());
envDef.getRecipients().setSigners([]);
envDef.getRecipients().getSigners().push(signer);
(此代码示例源自 here。)