Get requests with body

k6 v0.26.1

I have an GET API call with a body payload and headers
http.get call seems to only consider params (headers)

How can I make a successful call?

Hi @paomegalul,

GET requests usually don’t need body, but if your API requires it, you can use the general http.request method. See docs: request( method, url, [body], [params] )

Example:

let requestData = {"key": "value"};

res = http.request('GET', 'https://test-api.k6.io/public/crocodiles/', requestData, {
  headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
});
1 Like

Thank you so much sir. This worked out perfectly for me