How to use the k6/http.put function in k6

To help you get started, we’ve selected a few k6 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jembi / hearth / performance / patient-updateCreate-stress.js View on Github external
const makePutRequest = () => {
  // The id being created here should be unique, otherwise an update will actually happen
  const id = `${Date.now() + Math.random()}`
  patient.id = id
  const response = http.put(`${BASE_URL}${RESOURCE_PATH}/${id}`,
    JSON.stringify(patient),
    {
      headers: {
        'Content-Type': 'application/json'
      },
      tags: {
        name: `Patient Update-Create Stress Test`
      }
    })
  check(response, {
    'status code is 201': r => r.status === 201
  })
}