This procedure assumes you have a Postman account already created.
Reftab API Documentation: www.reftab.com/api-docs
Start by generating API keys from your Reftab account.
Click, “Settings” > “API Keys” > “Create API Key“
Next, copy your public and private key.
Next, log into postman and enable the desktop agent.
Next, create a new “Collection”.
Use the variables tab to “Add New Variables”
Past your public / private keys:
Click “Update”.
Next, click “Pre-request Scripts”
Paste in the below JS code:
var CryptoJS = require("crypto-js");
const publicKey = pm.variables.get('public');
const secretKey = pm.variables.get('private');
let body = pm.request.body;
const method = pm.request.method;
if (method === 'GET' || method === 'DELETE') {
body=undefined;
}
const url = pm.request.url;
const now = new Date().toUTCString();
let contentMD5 = '';
let contentType = '';
if (body !== undefined) {
contentMD5=CryptoJS.MD5(body).toString();
contentType='application/json';
}
let signatureToSign = method + '\n' +
contentMD5 + '\n' +
contentType + '\n' +
now + '\n' +
url;
signatureToSign = unescape(encodeURIComponent(signatureToSign));
const token = btoa(CryptoJS.HmacSHA256(signatureToSign, secretKey));
let signature = 'RT ' + publicKey + ':' + token;
signature = signature.replace("\n", '');
pm.request.headers.add({
key: 'Authorization',
value: signature
});
pm.request.headers.add({
key: 'x-rt-date',
value: now
});
Click “update”.
Next to your collection, click the three dots icon and click, “Add Request”
Next, give the request a name and save it to your previously saved collection:
Next, add the URL of the GET request you’d like. In the image below, the URL is: “https://www.reftab.com/api/assets/1” this will GET the asset with an id of ‘1’.
Click “Send” and the response should display: