# Pre request script is not added in the code

**URL:** <https://community.postman.com/t/pre-request-script-is-not-added-in-the-code/16933>\
**Category:** Help Hub\
**Created:** [October 20, 2020, 1:57pm UTC](https://community.postman.com/t/pre-request-script-is-not-added-in-the-code/16933 "2020-10-20T13:57:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MouadUser](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@MouadUser](https://community.postman.com/u/MouadUser)\
**Post date:** [October 20, 2020, 1:57pm UTC](https://community.postman.com/t/pre-request-script-is-not-added-in-the-code/16933/1 "2020-10-20T13:57:55Z")

</div>

Hello,

in Postman i configured a POST request and i adding a pre request Script. It works.  
I want to get the javascript code of this configuration to use the javascript code in another software.

 ![Bildschirmfoto 2020-10-20 um 15.44.02](https://us1.discourse-cdn.com/getpostman/original/3X/9/2/928435e47dfc7bd3b054aeea0af3dffffa143b61.png)

Postman provides the following javascript code:

function test3(){

var myHeaders = new Headers();  
myHeaders.append(“Content-Type”, “application/xml”);  
myHeaders.append(“Authorization”, “Basic SDYyNDIxOTpJTklUMTI=”);  
myHeaders.append(“Cookie”, “MYSAPSSO2=AjQxMDMBABhIADYAMgA0ADIAMQA5ACAAIAAgACAAIAACAAY5ADAAMwADABBSADgAMQAgACAAIAAgACAABAAYMgAwADIAMAAxADAAMQA5ADEANgAzADUABQAEAAAACAYAAlgACQACRQD%2fAVYwggFSBgkqhkiG9w0BBwKgggFDMIIBPwIBATELMAkGBSsOAwIaBQAwCwYJKoZIhvbW11bml0eTETMBEGA1UECxMKU0FQIFdlYiBBUzEUMBIGA1UECxMLZIhvcNAQkEMRYEFMAsejBHpu2v%21B7jBx2AC%2fUo%21qi6MAkGByqGSM44BAMELjAsAhR30l9O28C%2f89PQWdFNDbNi7ggfHQIUYq8EZfFoKmfwi9sVbxPl0l2hjNc%3d; sap-XSRF\_R81\_903=ochfTwkdp-W1ZqtguEdO\_A%3d%3d20201019163607SqHF9bZi1gsiZGTtDI\_9jSsO8pgb-RL9NM7WddqsTj0%3d”);

var raw = “\<?xml version=\"1.0\" encoding=\"utf-8\"?\>\<entry xml:base="[http://odataServer.de](http://odataServer.de)" xmlns="[http://www.w3.org/2005/Atom\](http://www.w3.org/2005/Atom%5C)” xmlns:m="[http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\](http://schemas.microsoft.com/ado/2007/08/dataservices/metadata%5C)" xmlns:d="[http://schemas.microsoft.com/ado/2007/08/dataservices\](http://schemas.microsoft.com/ado/2007/08/dataservices%5C)"\>\<content type="application/xml"\>\<m:properties\>\<d:ID\>1268535\</d:ID\>

var requestOptions = {  
method: ‘POST’,  
headers: myHeaders,  
body: raw,  
redirect: ‘follow’  
};  
fetch(“[https://odataserver.de](https://odataserver.de)”, requestOptions)  
.then(response =\> response.text())  
.then(result =\> console.log(result))  
.catch(error =\> console.log(‘error’, error));

}

you can see, Authorisation , cookie and content-type are added to the header, but the pre request Script content is not.

I muss add the pre request Script content to this java script code, else the logic is not working properly.

i tried:  
myHeaders.append(“PreRequest”, “test code test code test code”);  
but it doesnt work.

How can i add the pre Request content to the header?  
Any suggestions?

Thank you

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 20, 2020, 2:09pm UTC](https://community.postman.com/t/pre-request-script-is-not-added-in-the-code/16933/2 "2020-10-20T14:09:28Z")

</div>

The code inside the `Pre-request Scripts` and `Tests` sandbox is _only_ known to Postman and used _only_ in that context so it wouldn’t be part of the code snippet, as the selected language wouldn’t know how to execute it.
