How to pass form-data than normal raw body in auth rest call

Postman body have form-data . We need to pass same than plane body

sample code :

const authUrl = 'authurl';
const params = {
    headers: {
     'Content-Type': 'x-www-form-urlencoded',
     'Authorization' : 'Basic $encodedeValue'

let formData = { type : 'admin'};
let res =,formData,params);

but this is failing since data is going as json body / raw body while it should go as form-data .

Please advise.

Hi there,

Your Content-Type is incorrect, it should be application/x-www-form-urlencoded. But in this case you don’t have to specify it, as k6 will set it by default for you.

This is what the request looks like without specifying the Content-Type:

POST /post HTTP/1.1
Host: localhost:8000
User-Agent: k6/0.27.0 (
Content-Length: 10
Authorization: Basic $encodedeValue
Content-Type: application/x-www-form-urlencoded