fajarridikc / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

The remote server returned an error: (400) Bad Request. When uploading Video to youtube #594

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
this.youTubeAuthenticator = new ClientLoginAuthenticator(this.ApplicationName, 
ServiceNames.YouTube, this.credentials);

                this.youTubeAuthenticator.DeveloperKey = developerKey;

                YouTubeRequestSettings settings = new YouTubeRequestSettings(this.ApplicationName, developerKey, username, password);
                YouTubeRequest request = new YouTubeRequest(settings);

                settings.Timeout = ((GDataRequestFactory)request.Service.RequestFactory).Timeout = 60 * 60 * 1000;
                settings.Maximum = 2000000000;

                Video newVideo = new Video();
                String filename = Path.Combine(dir, _fileName);
                string contentType = MediaFileSource.GetContentTypeForFileName(filename);

                newVideo.YouTubeEntry.MediaSource = new MediaFileSource(filename, contentType); ;

                AtomLink link = new AtomLink("http://uploads.gdata.youtube.com/resumable/feeds/api/users/" + credentials.Username + "/uploads");
                link.Rel = ResumableUploader.CreateMediaRelation;
                newVideo.YouTubeEntry.Links.Add(link);

                newVideo.Title = "title";

                newVideo.Tags.Add(new MediaCategory("Entertainment", YouTubeNameTable.CategorySchema));
                newVideo.Description = "Description";
                newVideo.YouTubeEntry.Private = true;
                newVideo.Keywords = "New Video";

                WebResponse response = this.ru.Insert(this.youTubeAuthenticator, newVideo.YouTubeEntry);

THE REQUEST WAS:

POST 
http://uploads.gdata.youtube.com/resumable/feeds/api/users/acromm@gmail.com/uplo
ads?upload_id=AEnB2UoybyjKTSXpUK02-IisPuG8F5URP6mEvBFnPkAdwT9RBE0faqkusEdxBGx9sW
hFOzO8qoxtZf83QrRWiwhXSNwXK0VzKg HTTP/1.1
X-GData-Key: 
key=AI39si6DxLsZncf1268Dr4BwIChZIPiA1pEn_CJuoGs2sFVBFVl25OUZycZbWNuDCLIxTng_rT7l
6Ll80KaCmMl1Lac254fS1Q
Authorization: GoogleLogin 
auth=DQAAANoAAACdu-L6kqfxNwIsU-Ae188azW3hlqO0mJztJSDMzI7naCNY5sf40e4oGF915vudnv6
5_FlZ9w-JOT-Cav4_8HjECMUqC2BuJTyNLqg4UFgHP-dpQPCxZEgJ1qpPRy1ofsv0KqE38QHL1GEA9Gw
Nn1PN2nypHqGaUlVp0euE_Yv8a87wZmEoDCAKoXavqWdBlBDqZKIpLmL44OPVC_jJ1EUwNj05W880yq-
Q1Bon7jvhSJ0bsshYW1XLtfak4VGJRcrUHV9CvpODnfBTMvBrcXziBgqFkI46fomSc0fShtv9FA

Content-Type: video/quicktime
Content-Range: bytes 0-2579273/2579274
Host: uploads.gdata.youtube.com
Content-Length: 2579274

THE RESPONSE WAS:

HTTP/1.1 400 Bad Request
Server: HTTP Upload Server Built on May 23 2012 16:01:58 (1337814118)
X-GData-User-Country: AR
Content-Type: application/vnd.google.gdata.error+xml
X-GUploader-UploadID: 
AEnB2UoybyjKTSXpUK02-IisPuG8F5URP6mEvBFnPkAdwT9RBE0faqkusEdxBGx9sWhFOzO8qoxtZf83
QrRWiwhXSNwXK0VzKg
Date: Wed, 06 Jun 2012 13:23:39 GMT
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Cache-Control: no-cache, no-store, must-revalidate
Content-Length: 196

<errors 
xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>Inva
lidRequestUriException</code><internalReason>Exception message 
unavailable</internalReason></error></errors>

Original issue reported on code.google.com by acr...@gmail.com on 6 Jun 2012 at 2:19

GoogleCodeExporter commented 8 years ago
The URL you are using to start the upload process is invalid, you have to use:

http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads

The authentication token that you submit with the request needs to identify the 
currently logged-in user:

https://developers.google.com/youtube/2.0/developers_guide_protocol_resumable_up
loads#Resumable_uploads

Original comment by ccherub...@google.com on 6 Jun 2012 at 5:46

GoogleCodeExporter commented 8 years ago
Thanks a lot!

Original comment by acr...@gmail.com on 6 Jun 2012 at 6:03