我在向播放列表添加视频时出现错误请求

时间:2014-09-02 12:33:59

标签: c# windows-8 youtube-api

我正在尝试将YouTube视频添加到观看后期的播放列表中,但作为响应,我收到错误的请求错误。

var request = new HttpRequest<YoutubePlaylistItem>();

request.Path = "/v3/playlistItems";
request.Method = HttpMethod.Post;
request.AddParameter("part", "snippet");
request.AddParameter("key", ApiKey);

if (this.authorizationData != null)
{
      request.Headers.Add("Authorization",
      this.authorizationData.TokenType + " " + this.authorizationData.AccessToken);
}

var playlistItem = new YoutubePlaylistItem();
playlistItem.Snippet = new YoutubeVideoSnippet();
playlistItem.Snippet.PlaylistId = playlistId;
playlistItem.Snippet.ResourceId = new ResourceId();
playlistItem.Snippet.ResourceId.VideoId = videoId;
playlistItem.Snippet.ResourceId.Kind = "youtube#video";
request.PostContent.Add(playlistItem);

var test = await request.SendAsync();

当我在API Explorer中尝试此请求时,它可以正常工作。任何想法为什么这在我的应用程序中不起作用?

0 个答案:

没有答案