Skip to content

Instantly share code, notes, and snippets.

@icemilo
Last active April 11, 2023 09:04
Show Gist options
  • Save icemilo/49426240b6e1e998655e32d34fa675b6 to your computer and use it in GitHub Desktop.
Save icemilo/49426240b6e1e998655e32d34fa675b6 to your computer and use it in GitHub Desktop.
Pre-Request Script for Ncloud API
const accessKey = pm.environment.get("accessKey")
const secret = pm.environment.get("secret")
const moment = require('moment');
const timestamp = moment().valueOf();
const message = pm.request.method + " " + pm.request.url.getPath() + "?" + pm.request.url.getQueryString() + "\n" + timestamp + "\n" + accessKey
const signature = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(message, secret));
pm.collectionVariables.set("currentTimestamp", timestamp);
pm.collectionVariables.set("signature", signature);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment