Same API Pass when using Playwright but fails while using K6

Hi,
I am trying to test an API - It is getting passed while using playwright (Screenshot -1) but fails while using K6.(screenshot 2)
For Playwright I am getting status code as 200
For K6 I am getting - 415
Am I missing something.

My Code

import http from ‘k6/http’;
import { check, sleep } from ‘k6’;

export const options = {
vus: 1,
iterations:1,
duration: ‘3s’
};

export default function () {
const url = ‘https://staging-jujdjdkdkdjdhytty.com/jdjdjdjdjdjdjdjdjjd/rest/services/QueryPricedTransactionsService/queryPricedTransactions’;
const body = JSON.stringify({
“pageSize”: “10000000”,
“pageNumber”: “1”,
“filterCriteria”: {
“criteriaType”: “S”,
“attributeName”: “accountId”,
“value”: “0023242G31Ghdhdhdhdhdndnd796L7”,
“operator”: “=”,
“logicalOperator”: “and”,
“filterCriterias”: [
{
“attributeName”: “transactionType”,
“value”: “N”,
“operator”: “=”,
“criteriaType”: “S”,
“logicalOperator”: “and”,
“filterCriterias”: [
{
“attributeName”: “fromDate”,
“value”: “31/12/2023”,
“operator”: “=”,
“criteriaType”: “S”,
“logicalOperator”: “and”,
“filterCriterias”: [
{
“attributeName”: “toDate”,
“value”: “31/03/2024”,
“operator”: “=”,
“logicalOperator”: “and”,
“criteriaType”: “S”
}
]
}
]
}
]
}

});
const params = {
headers: {
Accept: ‘application/json’,
Authorization: “Bearer eyJ0eXAiOi…”

}

};

const resp = http.post(url, body, params);
console.log(resp.status);
check(resp, { ‘status was 200’: (r) => r.status == 200 });
sleep(1);
}

This Got solved
I was missing ‘content-type’: ‘application/json’, in header

2 Likes