Hi ,
I am writing code to call SOAP services from 3rd party using X++ , below is my code ;
public static void testService(str _xmlNote) { System.Net.HttpWebRequest webRequest; System.Net.HttpWebResponse webResponse; System.IO.Stream stream; System.IO.StreamReader streamReader; CLRObject clrObject; System.Byte[] byte; System.Text.Encoding utf8; str url = "http://xxxxxxxxxx"; new InteropPermission(InteropKind::ClrInterop).assert(); clrObject = System.Net.WebRequest::Create( url); webRequest = clrObject; webRequest.Method = 'POST'; webRequest.ContentType = 'application/xml'; webRequest.MediaType = 'application/xml'; webRequest.ContentLength = byte.get_Length(); utf8 = System.Text.Encoding::get_UTF8(); byte = utf8.GetBytes(_xmlNote); stream = webRequest.GetRequestStream(); stream.Write(byte,0,byte.get_Length()); webResponse = webRequest.GetResponse(); streamReader = new System.IO.StreamReader(stream); Info(streamReader.ReadToEnd());
But it throw me error at highlighted line ( in green colour) - Microsoft.Dynamics.Ax.Xpp.ClrErrorException: WebException ---> System.Net.WebException: The remote server returned an error: (415) Unsupported Media Type. at System.Net.HttpWebRequest.GetResponse()
Please suggest me .