# Authorization header fields

**URL:** <https://community.postman.com/t/authorization-header-fields/34051>\
**Category:** Help Hub\
**Tags:** variables, authentication\
**Created:** [March 30, 2022, 1:41pm UTC](https://community.postman.com/t/authorization-header-fields/34051 "2022-03-30T13:41:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![smnkv](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@smnkv](https://community.postman.com/u/smnkv)\
**Post date:** [March 30, 2022, 1:41pm UTC](https://community.postman.com/t/authorization-header-fields/34051/1 "2022-03-30T13:41:06Z")

</div>

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](http://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!

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [March 30, 2022, 1:59pm UTC](https://community.postman.com/t/authorization-header-fields/34051/2 "2022-03-30T13:59:54Z")

</div>

Hi @smnkv

This link might help you with variables;

> **[Using variables | Postman Learning Center](https://learning.postman.com/docs/sending-requests/variables/#defining-variables-in-scripts)**
>
> Using variables: documentation for Postman, the collaboration platform for API development. Create better APIs—faster.

To get one long string, you would just drop your JS in the prereq tab like this;

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/3/a/3aae8bc9bd63f333ccf43409d2eb172d07ece481.png)

I’m not sure that gives you the expected output though…
