Hi all,
I need http response request for the below URL in ax…how to do this by code…
Hi all,
I need http response request for the below URL in ax…how to do this by code…
I got it…this is the code.
static void ExchRateTest(Args _args)
{
str url;
str exchRate = “”;
System.Net.HttpWebRequest httpRequest = null;
System.Net.HttpWebResponse httpResponse = null;
CLRObject clro = null;
System.IO.Stream stream = null;
System.IO.StreamReader streamReader = null;
;
url = “https://www.apilayer.net/api/live?access_key=ace499165bd24c3a88a186eff7a189d0”;
new InteropPermission(InteropKind::ClrInterop).assert();
clro = System.Net.WebRequest::Create(url);
httpRequest = clro;
httpResponse = httpRequest.GetResponse();
stream = httpResponse.GetResponseStream();
streamReader = new System.IO.StreamReader(stream);
exchRate = streamReader.ReadToEnd();
info(strFmt("%1 ",exchRate));
CodeAccessPermission::revertAssert();
}
Don’t forget to close all streams when you’re done with them, both when your code succeeded and when it threw an exception.
OK…sure.