Pm.request.headers not supported

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

  1. I have exported my collection from the postman.(My application related endpoints)
  2. I have exported the environments from postman.
  3. 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
  4. 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

Hi @sajitharnair, welcome to the community forum :tada:

postman-to-k6 has a bunch of unsupported features one of which is accessing pm.request.headers. So this is why you get that message.

The original project is also now archived and deprecated. There is a community fork that seems to also not have added support for this in particular. But you might have some luck reporting it and asking it to be fixed :person_shrugging:

You should also be able to directly set headers in the Postman[Request] as shown in this [postman-to-k6] Postman variables in body won't get replaced script. Wether that works for your case I don’t know as not enough of the script was shared.

Hope this helps you!