title: uploading video on youtube using youtube java client library api
body: <p>Following is the error:</p>
  
  <p>Sorry, your upload was invalid:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
  &lt;errors&gt;
  &lt;error&gt;
  &lt;domain&gt;yt:validation&lt;/domain&gt;
  &lt;code&gt;invalid_value&lt;/code&gt;
  &lt;locationtype='xpath'&gt;media:group/media:category[@scheme='http://gdata.youtube.com/schemas/2007/categories.cat']/text()&lt;/location&gt;
  &lt;/error&gt;
  &lt;/errors&gt;
  </code></pre>
  
  <p>Below is my code for video-upload:</p>
  
  <pre><code>public class YtUpload {
  
          public YtUpload() {
  
          try {
  
          String client_id = "abcd";
          String developer_key = "AI39si6Nb_onkYi1b7...";
      YouTubeService service = new YouTubeService(client_id,developer_key);
      service.setUserCredentials("xyz@gmail.com", "password");
      VideoEntry newEntry = new VideoEntry();
  
          YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();
      mg.setTitle(new MediaTitle());
      mg.getTitle().setPlainTextContent("My Test Game");
      mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "tech"));
      mg.setKeywords(new MediaKeywords());
      mg.getKeywords().addKeyword("conference");
      mg.setDescription(new MediaDescription());
      mg.getDescription().setPlainTextContent("My description");
      mg.setPrivate(false);
      mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "mydevtag"));
      mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "anotherdevtag"));
  
      newEntry.setGeoCoordinates(new GeoRssWhere(37.0,-122.0));
      //alternatively, one could specify just a descriptive string
      newEntry.setLocation("Mountain View, CA");
  
          MediaFileSource ms = new MediaFileSource(new File("c:\\largeV_smallA.mp4"), "video/quicktime");
      newEntry.setMediaSource(ms);
      String uploadUrl = "http://uploads.gdata.youtube.com/feeds/api/users/default/uploads";
      service.insert(new URL(uploadUrl), newEntry);
      } 
          catch (MalformedURLException e) {
          e.printStackTrace();
      } catch (IOException e) {
              e.printStackTrace();
      } catch (ServiceException se) {
          System.out.println("Sorry, your upload was invalid:");
          System.out.println(se.getResponseBody());
          return;
      }
      System.out.println("Video uploaded successfully!");
      }
  
      public static void main(String[] args) {
          new YtUpload();
      }}
  </code></pre>