# HTTP request code builder

Turn a method, URL, headers and body into ready-to-run curl, Python requests and JavaScript fetch code.

- Endpoint: `POST https://setget.net/v1/tools/http-request-build` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `http-request-build`
- Page: https://setget.net/tools/http-request-build

## Inputs

- `url` (required, string): The address to request.
- `method` (optional, string, default `"GET"`): The HTTP method.
- `headers` (optional, json): Request headers as a JSON object of names and values.
- `body` (optional, string): The request body, exactly as it should be sent.

## Example 1

```json
{"input":{"url":"https://api.example.com/items","method":"post","headers":{"Content-Type":"application/json"},"body":"{\"name\": \"Sam's\"}"}}
```

Result:

```json
{"curl":"curl -X POST 'https://api.example.com/items' \\\n  -H 'Content-Type: application/json' \\\n  --data-raw '{\"name\": \"Sam'\\''s\"}'","python":"import requests\n\nresponse = requests.request(\n    'POST',\n    'https://api.example.com/items',\n    headers={\n        'Content-Type': 'application/json',\n    },\n    data='{\"name\": \"Sam\\'s\"}',\n)\nprint(response.status_code)\nprint(response.text)","javascript":"const response = await fetch(\"https://api.example.com/items\", {\n  method: \"POST\",\n  headers: {\n    \"Content-Type\": \"application/json\"\n  },\n  body: \"{\\\"name\\\": \\\"Sam's\\\"}\"\n});\nconsole.log(response.status);\nconsole.log(await response.text());"}
```

## Example 2: A plain GET

```json
{"input":{"url":"https://example.com/health"}}
```

Result:

```json
{"curl":"curl 'https://example.com/health'","python":"import requests\n\nresponse = requests.request(\n    'GET',\n    'https://example.com/health',\n)\nprint(response.status_code)\nprint(response.text)","javascript":"const response = await fetch(\"https://example.com/health\", {\n  method: \"GET\"\n});\nconsole.log(response.status);\nconsole.log(await response.text());"}
```

**Is the request sent?** No. Only the code is produced. Run it yourself to make the request.

**How are quotes in my data handled?** Each snippet escapes them for its own language, so the body arrives exactly as you wrote it.

**Why is my JSON body a string?** The body is sent as written, byte for byte. Set the Content-Type header yourself, for example to application/json.
