api - 使用to和 DocuSign API尝试"send a document for signature from template" 时出现 415错误

  显示原文与译文双语对照的内容

我正在设置一个on应用程序,它将请求从模板创建的信封上的签名。 使用这里工具可以使用 ,但当我尝试使用creator函数的Zoho postURL() 做同样的事情时,我将从DocuSign得到以下响应:


Response Code = 415
Response Text = HTTP Error

这个帖子英镑似乎描述了同样的错误。 给出的响应不清楚,我找不到应该被更新的文档。

以下是我的一些创建者代码:


void test3()
{
//Login
username ="XXX";
usernameEmail ="XXX";
password ="XXX";
integratorKey ="XXX";
templateId ="XXX";
authenticateStr ="<DocuSignCredentials><Username>" + username +"</Username><Password>" + password +"</Password><IntegratorKey>" + integratorKey +"</IntegratorKey></DocuSignCredentials>";
loginUrl ="https://demo.docusign.net/restapi/v2/login_information";
loginHeaders = {"X-DocuSign-Authentication" : authenticateStr,"Accept" :"application/json" };
loginGet = getUrl(loginUrl, loginHeaders,false);
loginResponseCode = loginGet.get("responseCode");
loginResponseText = loginGet.get("responseText"); 
if (loginResponseCode!="200")
{
 info"Error calling webservice; status is" + loginResponseCode;
}

Creator无法正确处理响应,所以我必须在这里清理它


loginResponseText = loginResponseText.replaceAll("rn","");
loginResponseText = loginResponseText.getSuffix("[");
loginResponseText = loginResponseText.getPrefix("]");
loginResponseMap = loginResponseText.toMap();
info loginResponseMap;
baseUrl = loginResponseMap.get("baseUrl");
accountID = loginResponseMap.get(("accountId"));
url = baseUrl +"/envelopes";
headers = map();
headers.put("X-DocuSign-Authentication","{"Username":"XXX","Password":"XXX","IntegratorKey":"XXX"}");
requestBody2 ="{n "envelopeDefinition" : "{n "-xmlns" : "http://www.docusign.com/restapi",n ="xmlns:i":"http://www.w3.org/2001/XMLSchema-instance",n "emailSubject": "test email subject",n "emailBlurb": "test email blurb",n "templateId": "1D489D22-55D9-4320-8C16-28DE11C4AB09",n "status": "created",n "messageLock": "false"n}}";
envelopePOST = postUrl(url,requestBody2,headers,false);
postResponseCode = envelopePOST.get("responseCode");
postResponseText = envelopePOST.get("responseText");
info"envelopePOST =" + envelopePOST;
info"Response Code =" + postResponseCode;
info"Response Text =" + postResponseText;
}

to或者DocuSign可以帮助我找出我从上面链接到的DocuSign API测试人员获得的同样的结果。

时间: 作者:

问题在于你的请求 Content-Type 和请求主体,你正在发送。 如果你不在 DocuSign API调用中设置 Content-Type 头,那么它默认为 application/json 。 你正在设置的请求正文。


requestBody2 ="{n "envelopeDefinition" : "{n "-xmlns" : "http://www.docusign.com/restapi",n ="xmlns:i":"http://www.w3.org/2001/XMLSchema-instance",n "emailSubject": "test email subject",n "emailBlurb": "test email blurb",n "templateId": "1D489D22-55D9-4320-8C16-28DE11C4AB09",n "status": "created",n "messageLock": "false"n}}";

无效看起来你正在使用的是xml和json的组合,而DocuSign将不接受。

你是否浏览过 DocuSign开发人员中心? 如果你通过快速入门部分,它最终会导致API工具部分,其中有两个重要的工具,这些工具在这里非常有用。 我猜根据你的代码你正在使用 python 。 因这里,检查具有 9个API使用例子的python 代码的API演练,包括从模板发送文档:

http://iodocs.docusign.com/apiwalkthroughs

例如下面是用于从模板发送文档的python 代码:


# DocuSign API Walkthrough 01 (PYTHON) - Request Signature from Template
import sys, httplib2, json;

# Enter your info:
username ="***";
password ="***";
integratorKey ="***";
templateId ="***";

authenticateStr ="<DocuSignCredentials>" 
"<Username>" + username +"</Username>" 
"<Password>" + password +"</Password>" 
"<IntegratorKey>" + integratorKey +"</IntegratorKey>" 
"</DocuSignCredentials>";
#
# STEP 1 - Login
#
url = 'https://demo.docusign.net/restapi/v2/login_information' 
headers = {'X-DocuSign-Authentication': authenticateStr, 'Accept': 'application/json'}
http = httplib2.Http()
response, content = http.request(url, 'GET', headers=headers)

status = response.get('status');
if (status!= '200'): 
 print("Error calling webservice, status is: %s" % status); sys.exit();

# get the baseUrl and accountId from the response body
data = json.loads(content);
loginInfo = data.get('loginAccounts');
D = loginInfo[0];
baseUrl = D['baseUrl'];
accountId = D['accountId'];

#--- display results
print ("baseUrl = %snaccountId = %s" % (baseUrl, accountId));

#
# STEP 2 - Create an Envelope with a Recipient and Send...
#

#construct the body of the request in JSON format 
requestBody ="{"accountId": "" + accountId +""," + 
""status": "sent"," + 
""emailSubject": "API Call for sending signature request from template"," + 
""emailBlurb": "This comes from Python"," + 
""templateId": "" + templateId +""," + 
""templateRoles": [{" + 
""email": "" + username +""," + 
""name": "Name"," + 
""roleName": "Role" }] }";

# append"/envelopes" to baseURL and use in the request
url = baseUrl +"/envelopes";
headers = {'X-DocuSign-Authentication': authenticateStr, 'Accept': 'application/json'}
http = httplib2.Http()
response, content = http.request(url, 'POST', headers=headers, body=requestBody);
status = response.get('status');
if (status!= '201'): 
 print("Error calling webservice, status is: %s" % status); sys.exit();
data = json.loads(content);
envId = data.get('envelopeId');

#--- display results
print ("Signature request sent! EnvelopeId is: %sn" % envId);

作者:
...