Hey guys
I am currently working with rest api / http requests and I figured out i’d better use Postman to test if i can connect to other server’s API.
Never used Postman before so got stuck.
That’s my JS code:
const ts = (Date.now()).toString();
const nonce = (Number(Date.now())*77).toString();
const httpreqmet = "POST";
const httprequri = "/v2/sms";
const httphost = "somewebsite.com";
const httpport = "443";
const httpopdata = "";
const lf = "\n"
const longstring = ts+lf+nonce+lf+httpreqmet+lf+httprequri+lf+httphost+lf+httpport+lf+httpopdata+lf;
How can I add longstring as variable on pre request script on Postman?
I have done the easiest part:
pm.globals.set(“ts”, “(Date.now()).toString()”);
pm.globals.set(“nonce”, “(Number(Date.now())*77).toString()”);
pm.globals.set(“httpreqmet”, “POST”);
pm.globals.set(“httprequri”, “/v2/sms”);
pm.globals.set(“httphost”, “somewebsite.com”);
pm.globals.set(“httpport”, “443”);
pm.globals.set(“httpopdata”, “”);
pm.globals.set(“lf”, “\n”);
should var longstring be:
pm.globals.set(“longstring”, pm.globals.get(ts)+pm.globals.get(lf)+pm.globals.get(nonce ) etc etc);
??
Thanks!