Dear All,
I am new to postman to K6 tool and while running the performance load testing I am getting the below error.
ERRO[0002] Error: pm.request.headers not supported
- I have exported my collection from the postman.(My application related endpoints)
- I have exported the environments from postman.
- Running the below command in powershell to generate the k6 script for the performance Load testing.
postman-to-k6 collection.json -e environment.json -o k6-script.js - I ran the “k6 run k6-script.js” command to run the performance load testing.
At this stage I receive this error.
My collection is having these parameters in the json file. Please find as below.
“event”: [
{
“listen”: “prerequest”,
“script”: {
“type”: “text/javascript”,
“exec”: [
“pm.request.headers.add({key: ‘Content-Type’, value: "application/json"});”,
“pm.request.headers.add({key: ‘itsapp-so’, value: "{{header__itsapp-so}}" });”,
“pm.request.headers.add({key: ‘itsapp-lang’, value: "{{header__ITSAPP_LANG}}" });”,
“pm.request.headers.add({key: ‘itsapp-ver’, value: "{{header__itsapp-ver}}" });”,
“pm.request.headers.add({key: ‘itsapp-deviceid’, value: "{{header__itsapp-deviceid}}" });”,
“pm.request.headers.add({key: ‘itsapp-device’, value: "{{header__itsapp-device}}" });”
]
}
},
And my K6 script also has the method as below.
export default function() {
group(“Product *”, function() {
postman[Pre].push(() => {
pm.request.headers.add({
key: “Content-Type”,
value: “application/json”
});
pm.request.headers.add({
key: “itsapp-so”,
value: “{{header__itsapp-so}}”
});
pm.request.headers.add({
key: “itsapp-lang”,
value: “{{header__ITSAPP_LANG}}”
});
pm.request.headers.add({
key: “itsapp-ver”,
value: “{{header__itsapp-ver}}”
});
pm.request.headers.add({
key: “itsapp-deviceid”,
value: “{{header__itsapp-deviceid}}”
});
pm.request.headers.add({
key: “itsapp-device”,
value: “{{header__itsapp-device}}”
});
});
I am not understanding what went wrong? Please let me know if you need any further information.
Any kind of help would be appreciated.
Thanks in advance,
Sajitha