Junior — Middle
What HTTP methods have you used in your projects?
sobes.tech AI
Answer from AI
In C# projects, I most often used the following HTTP methods:
- GET — to retrieve data from the server without changing the state.
- POST — to create new resources or send data to the server.
- PUT — to update existing resources entirely.
- PATCH — for partial updates of a resource.
- DELETE — to delete resources.
Example of using HttpClient for a GET request in C#:
using var client = new HttpClient();
var response = await client.GetAsync("https://api.example.com/items");
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}