function is_disabled(str) { return str == true; } function is_empty(str) { if (typeof str == 'undefined' || !str || str.length === 0 || str === "" || !/[^\s]/.test(str) || /^\s*$/.test(str) || str.replace(/\s/g,"") === "") { return true; } else { return false; } } pm.sendRequest('https://api.binance.com/api/v3/time', function(err, res) { console.log('Timestamp Response: ' + res.json().serverTime); pm.expect(err).to.not.be.ok; //var timestamp = res.json().serverTime; var timestamp = 123456; pm.environment.set("timestamp", timestamp) console.log("time:", timestamp) console.log("query", pm.request.url.query) let paramsObject = {}; const binance_api_secret = pm.variables.get("apisecret"); const binance_api_key = pm.variables.get("apikey"); const parameters = pm.request.url.query; console.log("secret", binance_api_secret) parameters.map((param) => { if (param.key != 'signature' && param.key != 'timestamp' && !is_empty(param.value) && !is_disabled(param.disabled)) { paramsObject[param.key] = param.value; } }) Object.assign(paramsObject, { 'timestamp': timestamp }); if (binance_api_secret) { const queryString = Object.keys(paramsObject).map((key) => { return `${encodeURIComponent(key)}=${paramsObject[key]}`; }).join('&'); console.log("Şifrelenecek queryString", queryString); const signature = CryptoJS.HmacSHA256(queryString, binance_api_secret).toString(CryptoJS.enc.Hex); pm.environment.set("signature", signature); pm.environment.set("binance-api-key", binance_api_key) console.log("signature", signature) console.log("apikey", binance_api_key) } })