Make HTTP/REST API calls using a C# script. Use this skill when you need to call REST APIs, fetch data from web services, send POST/PUT/DELETE requests, or test HTTP endpoints...
This skill enables you to make HTTP/REST API calls using a simple C# script that runs with dotnet run.
dotnet run app.cs support)Run the HTTP caller script using dotnet run:
dotnet run HttpCaller.cs -- <METHOD> <URL> [OPTIONS]
| Argument | Required | Description |
|---|---|---|
METHOD |
Yes | HTTP method: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS |
URL |
Yes | The full URL to call (must include scheme, e.g., https://) |
| Option | Description | Example |
|---|---|---|
--header or -H |
Add a header (can be used multiple times) | --header "Authorization: Bearer token123" |
--body or -b |
Request body (JSON string) | --body '{"name": "test"}' |
--body-file or -f |
Read request body from a file | --body-file request.json |
--timeout or -t |
Request timeout in seconds (default: 30) | --timeout 60 |
--output or -o |
Save response body to a file | --output response.json |
--verbose or -v |
Show detailed request/response info | --verbose |
--help or -? |
Show help and usage information | --help |
dotnet run HttpCaller.cs -- GET https://api.example.com/users
dotnet run HttpCaller.cs -- GET https://api.example.com/users --header "Authorization: Bearer YOUR_TOKEN_HERE"
dotnet run HttpCaller.cs -- POST https://api.example.com/users --header "Content-Type: application/json" --body '{"name": "John Doe", "email": "john@example.com"}'
dotnet run HttpCaller.cs -- PUT https://api.example.com/users/123 --header "Content-Type: application/json" --body-file update-user.json
dotnet run HttpCaller.cs -- DELETE https://api.example.com/users/123 --header "Authorization: Bearer YOUR_TOKEN_HERE"
dotnet run HttpCaller.cs -- POST https://api.example.com/data --header "Content-Type: application/json" --header "Authorization: Bearer TOKEN" --header "X-Custom-Header: value" --body '{"data": "test"}'
dotnet run HttpCaller.cs -- GET https://api.example.com/slow-endpoint --timeout 120 --verbose
dotnet run HttpCaller.cs -- GET https://api.example.com/large-data --output data.json
The HTTP caller script is located at: HttpCaller.cs
The script outputs:
=== HTTP Response ===
Status: 200 OK
Body:
{
"id": 123,
"name": "John Doe",
"email": "john@example.com"
}
=== HTTP Request ===
Method: POST
URL: https://api.example.com/users
Headers:
Content-Type: application/json
Authorization: Bearer ***
Body:
{"name": "John Doe", "email": "john@example.com"}
=== HTTP Response ===
Status: 201 Created
Headers:
Content-Type: application/json
X-Request-Id: abc123
Body:
{
"id": 456,
"name": "John Doe",
"email": "john@example.com"
}
The script provides clear error messages for common issues:
When using this skill, fill in:
Content-Type, Authorization, etc.Always include Content-Type: application/json header when sending JSON data.