DocuSign REST API INVALID_CONTENT_TYPE sending envelope from template with application/json

*爱你&永不变心* 提交于 2020-12-13 03:52:52

问题


I am using Google Apps Script to make a URL request to https://demo.docusign.net/restapi/v2.1/accounts/ACCOUNT-ID/envelopes (where ACCOUNT-ID is my proper numerical account ID.)

It's being sent with the code UrlFetchApp.fetch(url, params).

params is

{
  muteHttpExceptions: true,
  method: "POST",
  headers: {
    Authorization: "Bearer "+jwt,
    ContentType: "application/json"
  },
  payload: payload
}

jwt is a token retrieved from the JWT auth flow at execution time, and payload is

{
  "accountId": accountID,
  "emailSubject": subject,
  "templateId": templateID,
  "templateRoles": [{
    "email": data['email'],
    "name": data['name'],
    "roleName": "Seller",
    "tabs": {
      "textTabs": [
        {"tabLabel": "Seller", "value": data['name']},
        ...
      ]
    }
  }],
  "status": "sent"
}

Variables used here are defined as expected in a manner consistent with the example given by DocuSign

When I execute this, I get the following response with an HTTP 415. {"errorCode":"INVALID_CONTENT_TYPE","message":"Content Type specified is not supported."}

I have tried removing the ContentType header, passing the payload as a string, and both at once, to no avail. I also tried providing the GUID instead of the numerical ID for accountID, but it came out the same.


回答1:


Content type should be specified as Content-Type (with a -) inside headers object or as contentType inside params or options object. payload should also be JSON.stringifyied.



来源:https://stackoverflow.com/questions/59848872/docusign-rest-api-invalid-content-type-sending-envelope-from-template-with-appli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!