Put Request Using k6

As we learned in our first tutorial about what is k6 and why do we need to use k6 for load testing purpose. If you have not read my article on it yet please read before you read this article.

What is k6?

How to make put request using k6?

Sometimes you want to load test put endpoint where you need to send some payload along with some custom headers.

Check out following script that makes put request with some payload:

import http from 'k6/http';

export default function () {

  // send custom payload/put data
  const payload = JSON.stringify({
    name: 'Bert'

  // send put request with custom header and payload
  const response = http.put('https://httpbin.test.k6.io/put', payload, {
    headers: {
      'Content-Type': 'application/json',

  // show response code in console

Now, run above script to see the results on your terminal:

k6 run test.js