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.
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" xmlns="http://www.w3.org/2005/Atom\” xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices\"><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”, 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