I am trying to send xml request and it doesn't seem to be working. Can anyone see any problems with my code? I tried the parameters manually on the encoding site and it works fine, so my ftp and all is setup correctly.
Code:
protected void SendVideo_Click(object sender, EventArgs e)
{
string FileLocation = "[URL unfurl="true"]http://216.204.172.199/videos/test.avi";[/URL]
string sURL = "[URL unfurl="true"]http://manage.encoding.com";[/URL]
string UserId = "346";
string UserKey = "someuserkey";
string Action = "AddMedia";
string Notify = "per@hotmail.com";
string Destination = "ftp://EncodingAccount:password@216.204.172.199/videos/test.flv";
string xml = "<?xml version = '1.0'?>" +
"<query>" +
"<userid>" + UserId + "</userId>" +
"<userkey>" + UserKey + "</userkey>" +
"<action>" + Action + "</action>" +
"<source>" + FileLocation + "</source>" +
"<notify>" + Notify + "</notify>" +
"<format>" + "<output>flv</output>" + "</format>" +
"<destination>" + Destination + "</destination>" +
"</query>";
Label1.Text = xml.ToString();
//Our postvars
byte[] buffer = Encoding.ASCII.GetBytes(xml);
//Initialisation, we use localhost, change if appliable
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(sURL);
//Our method is post, otherwise the buffer (postvars) would be useless
WebReq.Method = "POST";
//We use form contentType, for the postvars.
WebReq.ContentType = "application/x-[URL unfurl="true"]www-form-urlencoded";[/URL]
//The length of the buffer (postvars) is used as contentlength.
WebReq.ContentLength = buffer.Length;
//We open a stream for writing the postvars
Stream PostData = WebReq.GetRequestStream();
//Now we write, and afterwards, we close. Closing is always important!
PostData.Write(buffer, 0, buffer.Length);
PostData.Close();
//Get the response handle, we have no true response yet!
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
//Now, we read the response (the string), and output it.
Stream Answer = WebResp.GetResponseStream();
StreamReader _Answer = new StreamReader(Answer);
}