I have this script, I'm trying to convert this script to PowerShell but no luck, fails with 'Not Authorized' during Web Request (JS works fine). Please let me know if I'm missing anything.
Postman JS Code:
var apiKey = pm.environment.get("123456");
var apisecret = postman.getEnvironmentVariable("123456");
var seconds = Math.floor(((new Date().getTime())+200000)/1000);
postman.setEnvironmentVariable("sig",CryptoJS.MD5(apiKey+apisecret+seconds).toString());
PS Code:
$clientId = "123456"
$clientSecret = "123456"
$seconds = ([Math]::Floor((Get-Date).ToFileTimeUTC())+200000/1000)
$initialSig = "$clientId" + "$clientSecret" + "$seconds"
$md5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
$utf8 = New-Object -TypeName System.Text.UTF8Encoding
$sig = ([System.BitConverter]::ToString($md5.ComputeHash($utf8.GetBytes($initialSig)))).toLower().toString() -replace "-",""
Thank you.