Hello
i have fixed the error the only thing now stuck is how to change the value in xml date and airport code dynamically.
protected void Button1_Click(object sender, EventArgs e)
{
string xml = "~/postxmls/XMLFile1.xml";
string apiurl = " http://iata.api.mashery.com/athena/ndc192api";
string message = postXMLData(apiurl,xml);
}
public string read_xml(string xmlpath)
{
string transactxml = HttpContext.Current.Server.MapPath("~/postxmls/XMLFile1.xml");
var xmlDoc = new XmlDocument();
xmlDoc.Load(transactxml);
return xmlDoc.OuterXml;
}
public string postXMLData(string destinationUrl, string requestXml)
{
string xmlpath = read_xml(requestXml);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(destinationUrl);
byte[] bytes;
bytes = System.Text.Encoding.ASCII.GetBytes(xmlpath);
request.ContentType = "application/xml";
request.ContentLength = bytes.Length;
request.Method = "POST";
request.Headers.Add("Authorization-Key", "ptstg9gr5ajwcrve8n267hg9");
Stream requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();
HttpWebResponse response;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Stream responseStream = response.GetResponseStream();
string responseStr = new StreamReader(responseStream).ReadToEnd();
return responseStr;
}
return null;
}