Hey people so I kinda did try to ask this for some ago but never really got answered so the thing is that I'm currently trying to put the functionality from this site
http://stefansundin.com/stuff/youtube/youtube-copy-annotations.html[
^] into a c# app however every time I try to send the XML data to the url it returns a "403 Forbidden".
This behavior confuses me a lot since if I use the Chrome plugin called "PostMan" everything works and I get 200 OK returned EVERY time and the XML is identical also, as well the site works fine too.
I've tracked the problem to possibly have something to do with cookies not being access probably but I just can't seems to get the problem solved (as you can see from the outcommented lines)
My code is this: (If any one would like my XML data and/or full code please tell me so)
private void PostXML()
{
byte[] bytes = Encoding.UTF8.GetBytes(richTextBox1.Text.ToString());
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.youtube.com/annotations_auth/update2/");
request.Method = "POST";
request.AllowAutoRedirect = false;
CookieContainer cookies = new CookieContainer();
CookieCollection cookieCollection = cookies.GetCookies(request.RequestUri);
Stream requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode != HttpStatusCode.OK)
{
string message = String.Format("POST failed. Received HTTP {0}",
response.StatusCode);
throw new ApplicationException(message);
}
}
I'm getting this respond header info back when the error is thrown (However the set-cookie seems to change from time to time):
{X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Content-Type: text/html; charset=utf-8
Date: Thu, 15 May 2014 13:26:37 GMT
Expires: Tue, 27 Apr 1971 19:44:06 EST
Set-Cookie: VISITOR_INFO1_LIVE=8ccNBaFb8xo; path=/; domain=.youtube.com; expires=Wed, 14-Jan-2015 01:19:37 GMT,YSC=ii4JdoC39CY; path=/; domain=.youtube.com; httponly,PREF=f1=50000000; path=/; domain=.youtube.com; expires=Wed, 14-Jan-2015 01:19:37 GMT
Server: gwiseguy/2.0
P3P: CP="This is not a P3P policy! See http://support.google.com/accounts/bin/answer.py?answer=151657&hl=da for more info."
Cache-Control: no-cache
Content-Length: 0
X-XSS-Protection: 1; mode=block
}
So I was wondering what i can do to fix this so I in my C# app can get 200 OK returned aswel, any ideas?
Thanks a lot in regard - Jackie