在创建信封时使用DocuSign INVALID_CONTENT_TYPE

时间:2019-09-26 14:10:56

标签: node.js docusignapi

我正在将accesstoken与文档数据一起发送,但出现此错误。我是否以正确的顺序发送文档数据

bodyData = {
  "status": "sent",
  "emailSubject": "Sent from the DocuSign REST API",
  "documents": [{
    "documentId": "1",
    "name": "contract.pdf",
    "documentBase64": "base64 document bytes...",
  }],
  "recipients": {
    "signers": [{
      "email": "....",
      "name": "Jane Dough",
      "recipientId": "....",
      "routingOrder": "1",
    }]
  }
}

curl.setHeaders([
  `Authorization: Bearer ${auth}`,
  "Content-Type: application/x-www-form-urlencoded"
])
  .setBody(bodyData)
  .post(`https://demo.docusign.net/restapi/v2/accounts/${accountId}/envelopes`)
  .then(({ statusCode, body, headers }) => {
    console.log('body : ', body)

    return res.status(200).json({
      success: true,
      data: body
    });
  })
  .catch(e => {
    console.log(e);
  });
    } catch (err) {
  console.log("err : ", err);
  // next(Boom.badImplementation(err));
}

1 个答案:

答案 0 :(得分:0)

需要将content_type更改为application / json

此外,需要确保在请求中发送了正确的正文。

我还建议您考虑使用最新版本的eSig REST API 2.1

在此处查看此API的文档-https://developers.docusign.com/esign-rest-api/reference/Envelopes/Envelopes/create