DocuSign REST API INVALID_CONTENT_TYPE使用应用程序/ json从模板发送信封 [英] DocuSign REST API INVALID_CONTENT_TYPE sending envelope from template with application/json

查看:97
本文介绍了DocuSign REST API INVALID_CONTENT_TYPE使用应用程序/ json从模板发送信封的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Apps脚本向 https://demo.docusign.net/restapi/v2.1/accounts/ACCOUNT-ID/信封(其中ACCOUNT-ID是我正确的数字帐户ID。)

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.)

使用代码 UrlFetchApp.fetch(url,params)发送。

params

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

jwt 是一个在执行时从JWT身份验证流程中检索到的令牌,并且有效载荷

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"
}

此处使用的变量按照与 DocuSign给出的示例

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

执行此操作时,将收到HTTP 415响应。
{ errorCode: INVALID_CONTENT_TYPE, message:未指定内容类型支持。}

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

我尝试删除ContentType标头,将有效负载作为字符串传递,但一次都无效。我也尝试提供GUID代替accountID的数字ID,但是结果是一样的。

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.

推荐答案

内容类型应为指定为
标头对象内的内容类型 (带有-)或 <$ c在 params options 对象中的$ c> contentType 有效载荷也应为 JSON.stringify ied。

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.

这篇关于DocuSign REST API INVALID_CONTENT_TYPE使用应用程序/ json从模板发送信封的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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