2017-09-09 1 views
0

Java 웹 기반 응용 프로그램 개발. 내 YouTube 동영상 제목, 설명 또는 태그를 업데이트하려고합니다. 이전 코드는 완벽하게 작동했습니다. 갑자기 실행 요청을하면 갑자기 작동이 멈췄습니다. 주로 자바에서 주어진 코드 샘플을 사용했다. 아래는 주요 Java 파일의 코드 샘플입니다. 생성자에 값을 보냅니다. 나는 그것이 잘못주고있는 줄을 대담하게 만들었습니다. 갑자기이 문제에 직면 한 다른 사람이 있습니까? 그리고 그 결의안은 무엇입니까?Youtube 데이터 API가 작동하지 않음 - 비디오 메타 데이터 기능 업데이트

오류 --- 서비스 오류가 있습니다. 400 : 요청 메타 데이터가 잘못되었습니다. 14 : 01 : 20.567 [main] ERROR 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; 
     } 

답변

0

코드에서 굵은 선을 볼 수 없으므로 여기에 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.

+0

실행시 오류가 발생합니다. ** video videoResponse = updateVideosRequest.execute(); ** –

+0

실행시 오류가 발생합니다. ** video videoResponse = updateVideosRequest.execute(); ** 2.3 주 전 동일한 코드가 작동했습니다. 이제 멈췄다. 제목이나 설명 또는 태그 또는 모두 3 또는 2를 업데이트하고 있습니다. 코드는 제 프런트 엔드를 기반으로 처리됩니다. 카테고리 ID를 업데이트해야하는 이유는 무엇입니까? 업데이트를 요청하기 전에 이전에 있었던 카테고리 ID와 동일해야합니다. Google 샘플 코드조차도 카테고리 ID를 업데이트 할 때 아무 것도 필요하지 않다고 말합니다. @ [link] (https://developers.google.com/youtube/v3/code_samples/java#update_a_video) 태그 만 업데이트 중입니다. –

관련 문제