问题
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.stringify
ied.
来源:https://stackoverflow.com/questions/59848872/docusign-rest-api-invalid-content-type-sending-envelope-from-template-with-appli