Continuous integration 如何将释放的api与salesforce集成?
我需要将UnlashedApi与salesforce集成。我在试着打电话。但是,得到的错误就像Continuous integration 如何将释放的api与salesforce集成?,continuous-integration,Continuous Integration,我需要将UnlashedApi与salesforce集成。我在试着打电话。但是,得到的错误就像 09:44:27:938 USER_DEBUG [17]|DEBUG|{"Description":"(403) Forbidden.: Authentication denied - signature mismatch. Username: \u0027 abc@gmail.com\u0027; OrganisationId: \u002757babb16-e109-461d-b993-87b6
09:44:27:938 USER_DEBUG [17]|DEBUG|{"Description":"(403) Forbidden.: Authentication denied - signature mismatch. Username: \u0027 abc@gmail.com\u0027; OrganisationId: \u002757babb16-e109-461d-b993-87b6bd214557\u0027; Signature: \u0027******\u0027; Url: \u0027/Customers/\u0027","DebugInformation":null}
以下是我的代码片段:
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setHeader('content-type', ' application/json');
req.setHeader('Accept',' application/json ');
req.setHeader('api-auth-id','57babb16-e109-461d-b993-87b6bd214557');
req.setHeader('auth-signature-method','HMAC-SHA256');
req.setHeader('api-auth-signature','1SMZNxnb9Tetc7MtDDxgOFUsB8zL2cGl2477ODH5AqEgpRt4N3tljd27omilAbyQGr3PqVPZstYIZKPC503w==');
req.setEndpoint( 'https://api.unleashedsoftware.com/Customers/');
Http http = new Http();
try {
HTTPResponse res = http.send(req);
res.getbody();
System.debug(res.toString());
System.debug(res.getbody());
System.debug('STATUS:'+res.getStatus());
System.debug('STATUS_CODE:'+res.getStatusCode());
} catch(System.CalloutException e) {
}
我如何解决问题并获得回复
string ApiId = 'API-ID';
string ApiKey = 'API KEY';
Blob blobSignature = Crypto.generateMac('HMACSHA256', Blob.valueOf(''), Blob.valueOf(ApiKey));
String base64 = EncodingUtil.base64Encode(blobSignature);
system.debug('>>>>>>>>> HASH ' + base64);
HttpRequest req = new HttpRequest();
req.setEndpoint('https://api.unleashedsoftware.com/Products');
req.setMethod('GET');
req.setHeader('Content-Type', 'application/json');
req.setHeader('Accept','application/json');
req.setHeader('api-auth-id',ApiId);
req.setHeader('api-auth-signature',base64);
Http http = new Http();
HTTPResponse res = http.send(req);
system.debug('>>>>>>>>>>>>>>>> RESOPNSE ' + res.getBody() );
system.debug('>>>>>>>>>>>>>>>> STATUS ' + res.getstatus() );
system.debug('>>>>>>>>>>>>>>>> STATUSCODE ' + res.getstatuscode() );