For a deeper look into our World Check One API, look into:

Overview |  Quickstart |  Documentation |  Downloads

question

Upvotes
Accepted
22 8 12 12

Using world check one API in salesforce returns 401 Unauthorized error?

We have used the API Key and API secret from postman collection. Trying to request for the group id from Salesforce returns 401 Unauthorized error. When accessed via postman we are getting the expected result but not in Salesforce. Do we need any special authorization key other than that?Need advice

world-checkworld-check-oneapierror-401
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
3.1k 16 7 7

Hi @baskaran.subramanian

There are a number of common errors developers make when first learning the WC1 API. With the same API keys and the properly coded authorization and headers it should work.

If you're programming in C# or Java, go to Downloads->CODE EXAMPLES and download the GET & POST examples, the GET example has the proper code for the groups endpoint.

----

I also have a WC1 API Overview and Quick Start video I'll be posting the Developer Community next week that may help. While the video addresses the common errors through the Postman Collection, several of the errors are generic and the likely root cause of programming errors when first developing your WC1 API solution. Also search Q&A for 401 and review the issues that were posted by other developers who's coding errors were found and corrected.

Here's a slide from the video.

Brian

function generateAuthHeader(dataToSign){
    var hash = CryptoJS.HmacSHA256(dataToSign,environment["api-secret"]);
    return hash.toString(CryptoJS.enc.Base64); 
}
var date = new Date().toGMTString();
var dataToSign = "(request-target): get " + environment["gateway-url"] + "groups\n" +
        "host: " + environment["gateway-host"] + "\n" +
        "date: " + date;
var hmac = generateAuthHeader(dataToSign);
var authorisation = "Signature keyId=\"" + environment["api-key"] + "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date\",signature=\"" + hmac + "\"";
postman.setEnvironmentVariable("authorisation",authorisation);
postman.setEnvironmentVariable("currentDate",date);


slide18d.jpg (67.2 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
3.1k 16 7 7
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
22 8 12 12

Hi @brian.bourgault,

I tried to watch the video but it is saying that the video is unavailable. Please advice.

Thanks,

Baskaran

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.