No results for

Powered byAlgolia
⚠️ This is the archived documentation for k6 v0.46. Go to the latest version.

request( method, url, [body], [params] )

methodstringRequest method (e.g. 'POST'). Must be uppercase.
urlstring / HTTP URLRequest URL (e.g. '').
body (optional)string / object / ArrayBufferRequest body; Objects will be x-www-form-urlencoded encoded.
params (optional)objectParams object containing additional request parameters.


ResponseHTTP Response object.


Using http.request() to issue a POST request:

import http from 'k6/http';
const url = '';
export default function () {
const data = { name: 'Bert' };
// Using a JSON string as body
let res = http.request('POST', url, JSON.stringify(data), {
headers: { 'Content-Type': 'application/json' },
console.log(res.json(); // Bert
// Using an object as body, the headers will automatically include
// 'Content-Type: application/x-www-form-urlencoded'.
res = http.request('POST', url, data);
console.log(res.json(); // Bert