Paba
Paba

Reputation: 1115

Error with long descriptions in Youtube Video Upload through Youtube API

I am trying to upload a video to youtube through youtube direct upload. It works fine. And then I created a video with a very long description. Then I'm getting the following error;

com.google.gdata.util.InvalidEntryException: Bad Request

<?xml version='1.0' encoding='UTF-8'?><errors><error><domain>yt:validation</domain><code>too_long</code><location type='xpath'>media:group/media:description/text()</location></error></errors>

I wonder whether it's due to the length of the description or could that be due to some other reason?

Given below is my Code

private String uploadVideo(YouTubeService service, String videoLocation,String mimeType,String title) throws InterruptedException, ExecutionException, TimeoutException, ServiceException, IOException {
    String id = "";
    File videoFile = new File(videoLocation);
    if (!videoFile.exists()) {
        System.out.println("Sorry, that video doesn't exist.");

    }
    String videoTitle = title;
    VideoEntry newEntry = new VideoEntry();
    YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();
    mg.setTitle(new MediaTitle());
    mg.getTitle().setPlainTextContent(videoTitle);
    mg.setKeywords(new MediaKeywords());
    mg.getKeywords().addKeyword("yt:crop=16:9");
    mg.setDescription(new MediaDescription());
    mg.getDescription().setHtmlContent(attributionDocument);
    mg.setPrivate(true);
    mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "Tech"));


    MediaFileSource ms = new MediaFileSource(videoFile, "video/quicktime");
    newEntry.setMediaSource(ms);

    String uploadUrl =
      "http://uploads.gdata.youtube.com/feeds/api/users/default/uploads";

    VideoEntry createdEntry = service.insert(new URL(uploadUrl), newEntry);
    id =createdEntry.getId();
    return id;

    }

I'll be really grateful if someone can help me with this.

Thanks in advance.

Upvotes: 1

Views: 819

Answers (1)

Stephen C
Stephen C

Reputation: 719661

The response XML says "too_long" about "media:group/media:description/text()". That's pretty conclusive to me.

Use a shorter description and the problem should go away.


FWIW, this link says what the media:description is supposed to contain, and it mentions that there are size limits.

Upvotes: 1

Related Questions