开发基于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,因为我看不到代码中的粗体行。

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

10-11 22:20
查看更多