Web アプリケーション コードを実行すると、この行でこのエラーが発生しました。
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()){}
実際、ブラウザで直接 URL を実行すると、適切な o/p が返されますが、コードで URL を実行すると。例外が発生します。
ここで MyCode は:-
string service = "http://api.ean.com/ean-services/rs/hotel/";
string version = "v3/";
string method = "info/";
string hotelId1 = "188603";
int hotelId = Convert.ToInt32(hotelId1);
string otherElemntsStr = "&cid=411931&minorRev=[12]&customerUserAgent=[hotel]&locale=en_US¤cyCode=INR";
string apiKey = "tzyw4x2zspckjayrbjekb397";
string sig = "a6f828b696ae6a9f7c742b34538259b0";
string url = service + version + method + "?&type=xml" + "&apiKey=" + apiKey + "&sig=" + sig + otherElemntsStr + "&hotelId=" + hotelId;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url) as HttpWebRequest;
request.Method = "POST";
request.ContentType = "text/xml";
request.ContentLength = 0;
XmlDocument xmldoc = new XmlDocument();
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
StreamReader responsereader = new StreamReader(response.GetResponseStream());
var responsedata = responsereader.ReadToEnd();
xmldoc = (XmlDocument)JsonConvert.DeserializeXmlNode(responsedata);
xmldoc.Save(@"D:\FlightSearch\myfile.xml");
xmldoc.Load(@"D:\FlightSearch\myfile.xml");
DataSet ds = new DataSet();
ds.ReadXml(Request.PhysicalApplicationPath + "myfile.xml");
GridView1.DataSource = ds.Tables["HotelSummary"];
GridView1.DataBind();
}