c# request and response from remote server using xml or json

--

All public string Index()

{

HttpWebRequest requestJson = (HttpWebRequest)WebRequest.Create(“https://my-json-server.typicode.com/typicode/demo/comments");

//HttpWebRequest requestXml = (HttpWebRequest)WebRequest.Create(“https://www.tcmb.gov.tr/kurlar/today.xml");

HttpWebResponse response = (HttpWebResponse)requestJson.GetResponse();

String version = response.ProtocolVersion.ToString();

StreamReader reader = new StreamReader(response.GetResponseStream());

string s = “”;

string str = reader.ReadLine();

while (str != null)

{

Console.WriteLine(str);

str = reader.ReadLine();

s += str;

}

return s;

}

--

--

ilhan DEMİRTEPE
ilhan DEMİRTEPE

No responses yet