Sobes.tech
Junior — Middle

Can you list the main HTTP methods and their purposes?

sobes.tech AI

Answer from AI

Main HTTP methods and their purposes:

  • GET — request to retrieve a resource. Used for reading data without changing the server's state.
  • POST — send data to the server to create a new resource or perform an operation.
  • PUT — replace or update a resource at the specified URI.
  • DELETE — delete a resource.
  • HEAD — request headers of a resource without the body, used to check existence or metadata.
  • PATCH — partial update of a resource.
  • OPTIONS — request supported methods for a resource from the server.

Example usage in C# with HttpClient:

var client = new HttpClient();
var response = await client.GetAsync("https://example.com/api/data");
string content = await response.Content.ReadAsStringAsync();