Convert curl to C#

Paste your curl command below — the C# · HttpClient code is generated instantly, entirely in your browser.

// your code will appear here

How the curl to C# conversion works

The output targets .NET 5+: headers go on client.DefaultRequestHeaders, JSON POST/PUT/PATCH requests use PostAsJsonAsync style helpers, and basic auth (-u) becomes an AuthenticationHeaderValue("Basic", ...).

Example

curl -X POST https://api.example.com/orders \
  -H 'Content-Type: application/json' \
  -d '{"item": "coffee"}'

becomes:

using var client = new HttpClient();

var response = await client.PostAsJsonAsync(
    "https://api.example.com/orders",
    "{\"item\":\"coffee\"}");