java - Youtube Data-api代码停止工作-更新视频元数据功能

标签 java youtube youtube-api youtube-data-api

开发基于Java Web的应用程序。我在尝试更新我的YouTube视频标题,描述或标签的地方。早期的代码运行良好。当我发出执行请求时,它突然停止工作。通常,我使用了Java中给出的代码示例。下面是我来自主要java文件的代码示例。我正在发送构造函数中的值。我在给出错误的地方加粗了。是否还有其他人突然面临这一挑战。分辨率是多少?

错误-
发生服务错误:400:请求元数据无效。
14:01:20.567 [main]错误com.analytics.youtube.UpdateYoutubeContent-发生服务错误:400:请求元数据无效。

this.setConnection(Lists.newArrayList("https://www.googleapis.com/auth/youtube"),"updatevideo");
            logger.info("After Setting Connection");
            YouTube.Videos.List listVideosRequest = this.ytConn.videos().list("snippet").setId(this.sId);
            VideoListResponse listResponse = listVideosRequest.execute();
            List<Video> videoList = listResponse.getItems();
            if (videoList.isEmpty()) {
                //System.out.println("Can't find a video with ID: " + videoId);
                throw (new Exception("Can't find a video with ID: "+this.sId));
            }
            Video video = videoList.get(0);
            VideoSnippet snippet = video.getSnippet();
            if(this.sTitle != ""){
                snippet.setTitle(this.sTitle);
                System.out.println("Title");
            }
            if(this.sDescription != ""){
                snippet.setDescription(this.sDescription);   
                System.out.println("Description");
            }
            if(this.sTags.get(0) != ""){
                snippet.setTags(this.sTags);
                System.out.println("Tags");
            }
            System.out.println(this.sTitle);
            System.out.println(this.sDescription);
            System.out.println(this.sTags.get(0));
//            snippet.

            YouTube.Videos.Update updateVideosRequest = this.ytConn.videos().update("snippet", video);
            **Video videoResponse = updateVideosRequest.execute();**


            logger.info("Before Catch");
        }catch (GoogleJsonResponseException e) {
            logger.error("There was a service error: " + e.getDetails().getCode() + " : "
                    + e.getDetails().getMessage());
            throw e;
        }
        catch(Exception ex){ logger.info("Inside Catch");
            logger.error("Error Message--"+ ex.getMessage() + "  Cause--" + ex.getCause());
            throw ex;
        }

最佳答案

这是您遇到的possible errors,因为我看不到代码中的粗体行。

commentThreads

The following tables identify error messages that the API returns in response to calls related to commentThreads resources. These methods could also return errors listed in the Common errors section.

  • commentThreads.insert
  • commentThreads.update

comments

The following tables identify error messages that the API returns in response to calls related to comments resources. These methods could also return errors listed in the Common errors section.

  • comments.insert
  • comments.update

videos

The following tables identify error messages that the API returns in response to calls related to videos resources. These methods could also return errors listed in the Common errors section.

  • videos.insert - The request metadata is invalid. This error occurs if the request updates the snippet part of a video resource but does not set a value for both the snippet.title and snippet.categoryId properties.

  • videos.update - The request metadata is invalid. This error occurs if the request updates the snippet part of a video resource but does not set a value for both the snippet.title and snippet.categoryId properties.

关于java - Youtube Data-api代码停止工作-更新视频元数据功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46128852/

相关文章:

Java认证安全

java - 哪个 eclipse 包与 google app engine 一起使用?

java - 如何绘制列表中包含的多个 glQuad?

html - 我无法在 iFrame 中显示 YouTube 实时聊天

youtube - 了解 YouTube 视频是否受 GEMA 保护

video - 如何自动播放多个 youtube 视频并将它们静音?

javascript - 嵌入式 YouTube 视频中出现 “catching” 错误

java工厂模式问题

video - YouTube数据API-如何获取刚上传的视频的URL?

ruby-on-rails - 在Ruby on Rails应用程序中搜索和嵌入youtube视频