Post call is falling

Hi Team, Even though i am making POST call but on backend server i am getting a GET call and i can validate response using POSTMan too. When i am making get call from postman am am getting same response what i am getting fro K6 POST response.My Code is

 const url = 'https://MyServiceHost/ReadHelloWorld.v1';
  let headers = { 'Content-Type': 'application/json' };
  let data = "['Harish']";
  console.log(JSON.stringify(data))
  const before = new Date().getTime();
   
  group("POST", function() {
    let res = http.post(url, JSON.stringify(data), { verb: "post" });
    //let j = JSON.parse(res.body);
    console.log(">>>>>>>>>>"+res.body)
    check(res, {
        "status is 200": (r) => r.status === 200
    });
});
Response-

{"error":"(RECIPIENT_FAILURE,0) Timed out after waiting 20000(ms) for a reply. address: __vertx.reply.2539024, repliedAddress: ReadHelloWorld.v1/1.5.0"}  source=console

Hi @hksharma, welcome to the forum!

This seems like something that you server returns … I would expect this is the case because your request doesn’t seem quite right:

  1. JSON.stringify(data) will stringify something that is already a string and I would argue this is not what you want - you should just leave it.
  2. This { verb: "post" } means nothing to k6
  3. You should probably set your Content-Type to application/json by replacing the third argument with { headers: { "content-type": "application/json" } }

You can try --http-debug=full if you continue to have problems to see what is being sent and received.

Thanks @mstoykov.

Yes you are right since there is no Json then i should not use the JSON.stringify. Now its working fine.

Thanks for prompt response.