Http¶
static class · namespace Hazel
HTTP client for making web requests to JSON APIs and other services.
Methods¶
Get(string)¶
static
Performs an HTTP GET request and returns the response body as a string.
Parameters
| Name | Description |
|---|---|
url |
The URL to request |
Returns — Response body as string, or empty string on error
Get(string, string)¶
static
Performs an HTTP GET request with custom headers.
Parameters
| Name | Description |
|---|---|
url |
The URL to request |
headers |
Newline-separated headers (e.g. "Authorization: Bearer token\nX-Custom: value") |
Returns — Response body as string, or empty string on error
Post(string, string)¶
static
Performs an HTTP POST request with a JSON body. Content-Type: application/json is automatically set.
Parameters
| Name | Description |
|---|---|
url |
The URL to request |
jsonBody |
The JSON body to send |
Returns — Response body as string, or empty string on error
Post(string, string, string)¶
static
Performs an HTTP POST request with a JSON body and custom headers. Content-Type: application/json is automatically set.
Parameters
| Name | Description |
|---|---|
url |
The URL to request |
jsonBody |
The JSON body to send |
headers |
Newline-separated headers (e.g. "Authorization: Bearer token\nX-Custom: value") |
Returns — Response body as string, or empty string on error
Source: Hazel/Core/Http.cs