Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8964085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:30:22+00:00 2026-06-15T16:30:22+00:00

I am trying to dispatch a POST request to get an upload token from

  • 0

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.

I am trying to build the request as described by the following YouTube API documentation:
https://developers.google.com/youtube/2.0/developers_guide_protocol_browser_based_uploading#Browser_based_uploading

The following is my client-side GWT code:

// BODY
StringBuilder sb = new StringBuilder();
sb.append("<?xml version=\"1.0\"?>"
        + "<entry xmlns=\"http://www.w3.org/2005/Atom\""
        + "xmlns:media=\"http://search.yahoo.com/mrss/\""
        + "xmlns:yt=\"http://gdata.youtube.com/schemas/2007\">"
        + "<media:group>"
        + "<media:title type=\"plain\">MyTitle</media:title>"
        + "<media:description type=\"plain\">"
        + "My description."
        + "</media:description>"
        + "<media:category scheme=\"http://gdata.youtube.com/schemas/2007/categories.cat\">"
        + "People"
        + "</media:category>"
        + "<media:keywords>word1, word2</media:keywords>"
        + "</media:group>"
        + "</entry>");

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());
}

The following is my request as displayed in Chrome’s developer tools:

Request URL:https://gdata.youtube.com/action/GetUploadToken
Request Method:OPTIONS
Status Code:404 Not Found

Request Headers

: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

Response Headers

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

As seen above, I am getting a “404 Not Found” error after dispatching the request.

Any help would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:30:23+00:00Added an answer on June 15, 2026 at 4:30 pm

    I am not super familiar with GWT, but I noticed something peculiar. The request that Chrome is reporting is, in fact, an OPTIONS request, not a POST as the YouTube API requires. I am able to reproduce the 404 when sending an arbitrary OPTIONS request to this URL.

    Your code indicates that you are attempting to send a POST request. However, I assume this is a cross-origin request, which would be governed by the Same Origin Policy. Take a look at this example of cross-site requests using GWT. It is possible that the odd behavior of sending an OPTIONS request instead of a POST request is due to the code treating this as if it were a same-site request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send a POST request to a server using AFNetworking, and
I am trying to dispatch in a servlet request handler to the JSP processor
While trying to do: perl -I'/v1/data/site_perl' -MCPAN -e 'install Log::Dispatch'; I continue to get
I'm trying to get a file upload progress bar working in a rails 3
I am trying to save large files from Google App Engine's Blobstore to Google
I am trying to upload a File with one parameter using spring 3. This
I am trying to get some code working from an example I came across.
I'm trying to get a better grasp of structural type dispatch. For instance, assume
I am trying to post a message to my twitter account using Spring Integration
I'm using formtastic to collect information from a form and post dirctly to an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.