Articles → ASP .NET WEB API → Consume Web API Get Method Using C#
Consume Web API Get Method Using C#
Create Web API
public class TestController: ApiController {
public List < string > GetTrafficSignalColor() {
return new List < string > () {
"Red",
"Green",
"Orange"
};
}
}
Create C# Application
using(var client = new WebClient()) {
client.Headers["request-type"] = "application/json";
string result = client.DownloadString("http://localhost:19800/api/Test");
Console.WriteLine(result);
Console.ReadLine();
}
Output
Click to Enlarge