title: Status 404 After YouTube GetUploadToken Request Using GWT RequestBuilder
body: <p>I am trying to dispatch a POST request to get an upload token from YouTube using RequestBuilder from the client-side of my GWT app.</p>
  
  <p>I am trying to build the request as described by the following YouTube API documentation:
  <a href="https://developers.google.com/youtube/2.0/developers_guide_protocol_browser_based_uploading#Browser_based_uploading" rel="nofollow">https://developers.google.com/youtube/2.0/developers_guide_protocol_browser_based_uploading#Browser_based_uploading</a></p>
  
  <p>The following is my client-side GWT code:</p>
  
  <pre><code>// BODY
  StringBuilder sb = new StringBuilder();
  sb.append("&lt;?xml version=\"1.0\"?&gt;"
          + "&lt;entry xmlns=\"http://www.w3.org/2005/Atom\""
          + "xmlns:media=\"http://search.yahoo.com/mrss/\""
          + "xmlns:yt=\"http://gdata.youtube.com/schemas/2007\"&gt;"
          + "&lt;media:group&gt;"
          + "&lt;media:title type=\"plain\"&gt;MyTitle&lt;/media:title&gt;"
          + "&lt;media:description type=\"plain\"&gt;"
          + "My description."
          + "&lt;/media:description&gt;"
          + "&lt;media:category scheme=\"http://gdata.youtube.com/schemas/2007/categories.cat\"&gt;"
          + "People"
          + "&lt;/media:category&gt;"
          + "&lt;media:keywords&gt;word1, word2&lt;/media:keywords&gt;"
          + "&lt;/media:group&gt;"
          + "&lt;/entry&gt;");
  
  String requestBody = sb.toString();
  
  // HEADER
  RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, "https://" + YOUTUBE_HOST + "/action/GetUploadToken");
  rb.setHeader("Host", YOUTUBE_HOST);
  rb.setHeader("Content-Type", "application/atom+xml; charset=" + CHAR_ENCODING);
  rb.setHeader("X-GData-Key", MY_CLIENT_KEY);
  rb.setHeader("GData-Version", "2");
  try {
      rb.setHeader("Content-Length", Integer.toString(requestBody.getBytes(CHAR_ENCODING).length));
  }
  catch (UnsupportedEncodingException e) {
      Window.alert(e.getMessage());
  }
  rb.setHeader("Authorization", "Bearer " + AUTHORIZATION_CODE);
  
  // CALL
  try {
      rb.sendRequest(requestBody, new RequestCallback() {
          @Override
          public void onResponseReceived(Request request, Response response) {
              Document dom = XMLParser.parse(response.getText());
  
              Node urlNode = dom.getElementsByTagName("url").item(0);
              String url = urlNode.getFirstChild().getNodeValue();
  
              Node tokenNode = dom.getElementsByTagName("token").item(0);
              String token = tokenNode.getFirstChild().getNodeValue();
          }
  
          @Override
          public void onError(Request request, Throwable t) {
              callback.onFailure(t.getMessage());
          }
      });
  }
  catch (RequestException e) {
      callback.onFailure(e.getMessage());
  }
  </code></pre>
  
  <p>The following is my request as displayed in Chrome's developer tools:</p>
  
  <pre><code>Request URL:https://gdata.youtube.com/action/GetUploadToken
  Request Method:OPTIONS
  Status Code:404 Not Found
  </code></pre>
  
  <p><strong>Request Headers</strong></p>
  
  <pre><code>:host:gdata.youtube.com
  :method:OPTIONS
  :path:/action/GetUploadToken
  :scheme:https
  :version:HTTP/1.1
  accept:*/*
  accept-charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
  accept-encoding:gzip,deflate,sdch
  accept-language:en-GB,en-US;q=0.8,en;q=0.6
  access-control-request-headers:origin, x-gdata-key, authorization, content-type, gdata-version
  access-control-request-method:POST
  origin:http://127.0.0.1:8888
  referer:http://127.0.0.1:8888/MyApp.html?gwt.codesvr=127.0.0.1:9997
  user-agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11
  </code></pre>
  
  <p><strong>Response Headers</strong></p>
  
  <pre><code>cache-control:no-cache, no-store, max-age=0, must-revalidate
  content-encoding:gzip
  content-length:117
  content-type:text/html; charset=UTF-8
  date:Thu, 06 Dec 2012 14:29:20 GMT
  expires:Fri, 01 Jan 1990 00:00:00 GMT
  pragma:no-cache
  server:GSE
  status:404 Not Found
  version:HTTP/1.1
  x-content-type-options:nosniff
  x-frame-options:SAMEORIGIN
  x-gdata-user-country:US
  x-xss-protection:1; mode=block
  </code></pre>
  
  <p>As seen above, I am getting a "404 Not Found" error after dispatching the request.</p>
  
  <p>Any help would be greatly appreciated!</p>