If you want to connect to FieldClimate API with HMAC, you have to use the Pre-request Script on Postman.

+ The yellow highlighted variables are to be edited according to your needs and keys

+ We use the environment variable api.v2, which is set to https://api.fieldclimate.com/v2/

+ In the example below we run a HTTP GET request

+ the API route /user/stations is just an example, any other route is possible, but params (method and request) are to be changed accordingly

+ Your private and public HMAC key pair can be optained on https://fieldclimate.com > user menu > API services > FieldClimate, copy paste the keys from there to the script as indicated below



The Pre-requested Script for your request can look like this:



Here another example of the params section in the script for another route:


You can copy paste the script from here for use and editing:

let params = {
    "method" : "GET",
    "request": "/user"
}
const method = params.method
const body = params.body
const public_key = "YOUR_PUBLIC_KEY";
const private_key = "YOUR_PRIVATE_KEY";
const timestamp = new Date().toUTCString(); 
const content_to_sign = params.method + params.request + timestamp + public_key;
const signature = CryptoJS.HmacSHA256(content_to_sign, private_key);
const hmac_str = 'hmac ' + public_key + ':' + signature;

pm.environment.set("hmac", hmac_str);
pm.environment.set("ts", timestamp);





2 Header entries "Authorization" and "Request-Date" are to be added:



Including the default headers, the entries may look like this:




Remaining tabs:


+ Params: empty
+ Authorization: No Auth

+ Body: none, depends on the request of course, in the examples above we dont send data, therefore the body empty 

+ Tests: empty

+ Settings: