---
title: "request( method, url, [body], [params] ) | Grafana k6 documentation"
description: "Issue any type of HTTP request."
---

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

Expand table

| Parameter         | Type                                                                     | Description                                                                                               |
|-------------------|--------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
| method            | string                                                                   | Request method (e.g. `'POST'`). Must be uppercase.                                                        |
| url               | string / [HTTP URL](/docs/k6/latest/javascript-api/k6-http/url/#returns) | Request URL (e.g. `'http://example.com'`).                                                                |
| body (optional)   | string / object / ArrayBuffer                                            | Request body; Objects will be `x-www-form-urlencoded` encoded.                                            |
| params (optional) | object                                                                   | [Params](/docs/k6/latest/javascript-api/k6-http/params/) object containing additional request parameters. |

### Returns

Expand table

| Type     | Description                                                               |
|----------|---------------------------------------------------------------------------|
| Response | HTTP [Response](/docs/k6/latest/javascript-api/k6-http/response/) object. |

### Example

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

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
import http from 'k6/http';

const url = 'https://quickpizza.grafana.com/api/post';

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().name); // 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.body); // name=Bert
}
```
