public static void Main()
string content = "[\r\n {\r\n \"currency\": \"GBP\",\r\n \"country_code\": \"GBR\",\r\n \"side\": \"B\",\r\n \"qty\": 6937,\r\n \"px\": 19.915,\r\n \"comm\": 41.45,\r\n \"trade_date\": \"20230609\",\r\n \"rowID\": \"0\",\r\n \"symbol\": \"GB00B1YW4409\",\r\n \"res_in_xml\": true\r\n }\r\n]";
WebApiPostMethod(content, );
public static string WebApiPostMethod(string postData, string URL)
string ticker = string.Empty;
string responseFromServer = "";
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(URL);
request.SendChunked = true;
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
((System.Net.HttpWebRequest)request).UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)";
request.Accept = "text/plain";
request.UseDefaultCredentials = true;
request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/json";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
System.Net.WebResponse response = request.GetResponse();
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
responseFromServer = reader.ReadToEnd();
System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
xDoc.LoadXml(responseFromServer);
Console.WriteLine(responseFromServer);
return responseFromServer;