Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
put( url, [body], [params] )
Parameter | Type | Description |
---|---|---|
url | string /HTTP URL | Request URL (e.g. http://example.com ). |
body (optional) | string / object / ArrayBuffer | Request body; objects will be x-www-form-urlencoded . |
params (optional) | object | Params object containing additional request parameters. |
Returns
Type | Description |
---|---|
Response | HTTP Response object. |
Example
import http from 'k6/http';
const url = 'https://httpbin.test.k6.io/put';
export default function () {
const headers = { 'Content-Type': 'application/json' };
const data = { name: 'Bert' };
const res = http.put(url, JSON.stringify(data), { headers: headers });
console.log(JSON.parse(res.body).json.name);
}