Thursday, February 13, 2025

How to make an HTTP get request with parameters

 

Method-1

In a GET request, pass parameters as part of the query string.

 

                    string url = "http://inventory.com?invoice=12345";
 
Method-2
 
WebClient webClient = new WebClient();
webClient.QueryString.Add("param1", "value1");
webClient.QueryString.Add("param2", "value2");
string result = webClient.DownloadString("http://theurl.com"); 

No comments:

Post a Comment