You need to sign in to do that
Don't have an account?

salesforce rest api and javascript
I created javascript to test Rest APIs to an application from Postman. I am now trying to convert or rewrite it to be used in Salesforce to do the same. I am having a hard time in doing so. Any suggestions?
However if you are having any specific question or error then let us know and we would be happy to help.
I have been attempting to translating to Apex but I can't seem to get it right so I keep starting from scratch.
Get https://api.myapp.com/api/object
my pre-request Script in postman
Authorization set to no Auth
Headers:
Authorization = myToken
Date = myDate
var CryptoJS = require("crypto-js");
var privateKey = " ";
var publicKey = " ";
var uri = "/api/object/{value}";
var httpMethod = "get";
var now = new Date();
var rfc1123date = now.toUTCString();
pm.environment.set("myDate", rfc1123date);
var message = httpMethod + "|" + uri + "|" + rfc1123date.toLowerCase();
console.log(`message = ${message}`);
var hash = CryptoJS.HmacSHA256(message, privateKey).toString(CryptoJS.enc.Base64);
console.log(`hashInBase64 = ${hash}`);
var authMessage = publicKey + ":" + hash;
console.log(`authMessage = ${authMessage}`);
var token = btoa(authMessage);
console.log(`token = ${token}`);
pm.environment.set("myToken", token);