/// <summary>GET request to the api that responses in XML format</summary> /// <param name="url">String with url and parameters for GET request</param> /// <returns>Dynamic object with response data</returns> public static dynamic GetWithXmlResponse(string url) { var request = WebRequest.Create(url) as HttpWebRequest; request.Credentials = CredentialCache.DefaultNetworkCredentials; var xDoc = XDocument.Load(request.GetResponse().GetResponseStream()); return(XMLToDynamicConverter.Convert(xDoc.Elements().First())); }
/// <summary>GET request to the api that responses in XML format</summary> /// <param name="url">String with url</param> /// <param name="requestParameters">Parameters for GET request as key-value pairs</param> /// <returns>Dynamic object with response data</returns> public static dynamic GetWithXmlResponse(string url, IEnumerable <KeyValuePair <string, string> > requestParameters) { string urlWithParams = string.Format("{0}?{1}", url, KeyValueToStringConverter.Convert(requestParameters)); var request = WebRequest.Create(urlWithParams) as HttpWebRequest; request.Credentials = CredentialCache.DefaultNetworkCredentials; var xDoc = XDocument.Load(request.GetResponse().GetResponseStream()); return(XMLToDynamicConverter.Convert(xDoc.Elements().First())); }