通过apex登录Docusign API

时间:2014-08-05 16:18:47

标签: salesforce apex docusignapi

我正在尝试连接Docusign REST API制作' login_information'从Salesforce开发人员控制台调用,但遇到问题: '提供的网址无法解析为资源'。

这是我的代码:

private static final string TOKEN_URL = 'https://demo.docusign.net/restapi/v2/login_information';
private static final string userName = 'username';
private static final string password = 'password';
private static final string integrationKey = 'integrationKey';

string authenticationHeader = 
                '<DocuSignCredentials>' + 
                    '<Username>' + userName+ '</Username>' +
                    '<Password>' + password + '</Password>' + 
                    '<IntegratorKey>' + integrationKey  + '</IntegratorKey>' + 
                '</DocuSignCredentials>';           


HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();        

req.setEndpoint(TOKEN_URL);
req.setHeader('Content-Type', 'application/json');
req.setHeader('Accept', 'application/json');
req.setHeader('X-DocuSign-Authentication', authenticationHeader);
req.setMethod('GET');
req.setBody('');

res = http.send(req);

我可以使用我的凭据登录Docusign控制台,所以一切正确。但是不能通过Apex做同样的事情。可能是缺乏权限?

1 个答案:

答案 0 :(得分:1)

req.setBody(&#39;&#39);应该从代码中删除。它解决了这个问题。