DBA

HttpClient Class를 이용하여 API를 호출 본문

[3] Development/MVC(ASP.NET with C#)

HttpClient Class를 이용하여 API를 호출

코볼 2023. 2. 27. 12:52
728x90
반응형
SMALL

// GET 요청 예시
var response = await client.GetAsync("https://api.example.com/users");

 

// POST 요청 예시
var content = new StringContent(JsonConvert.SerializeObject(user), Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.example.com/users", content);

 

// PUT 요청 예시
var content = new StringContent(JsonConvert.SerializeObject(user), Encoding.UTF8, "application/json");
var response = await client.PutAsync("https://api.example.com/users/1", content);

 

// DELETE 요청 예시
var response = await client.DeleteAsync("https://api.example.com/users/1");

728x90
반응형
LIST
Comments