HTTP/Get query params


Hi there!
I want to send Get request of the following type:
And I also want to send some headers. Right now this looks like:
let res = http.get(endpoint +"?parameter=VALUE", { headers: headers });

Is there any way to send parameter not attached to url, but as some part of params object?


There isn’t anything like that included in the k6 libs, but you can pretty easily write a query builder in JS like this:

import http from "k6/http";

function buildQuery(data) {
   let result = [];
   Object.keys(data).forEach((key) => {
       result.push(encodeURIComponent(key) + "=" + encodeURIComponent(data[key]));
   return result.join("&");

export default function () {
   let urlQuery = buildQuery({ queryKey1: "someData=", queryKey2: "1254@@&%!" });
   let resp = http.put(`${urlQuery}`, { bodyKey1: "bval1", bodyKey2: "bval2" });
1 Like