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

  • Home
  • SEARCH
  • 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 6978015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:42:04+00:00 2026-05-27T17:42:04+00:00

I am working on application to upload video on YouTube from android. I know

  • 0

I am working on application to upload video on YouTube from android. I know we can not use API on android so we have to send a http post request to YouTube to upload video. Here is my code in which I am getting error Invalid Content-Type x-www-urlencode, code shows i have used Content-Type as application/atom+xml; charset=UTF-8 then why i am getting this type of error, any one can help me in this?

HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("https://www.google.com/accounts/ClientLogin");


List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("Content-Type", "application/x-www-form-urlencoded"));
pairs.add(new BasicNameValuePair("Email", "xxxx"));
pairs.add(new BasicNameValuePair("Passwd", "xxx"));
pairs.add(new BasicNameValuePair("service", "youtube"));
pairs.add(new BasicNameValuePair("source", "YouTubeApp"));


post.setEntity(new UrlEncodedFormEntity(pairs));

HttpResponse response = client.execute(post);

String textResponse = getResponseBody(response); 
String auth = textResponse.substring(textResponse.lastIndexOf("Auth"));

builder.setMessage(auth).show();

String entry = "<?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\">Bad Wedding Toast</media:title>"
     + "<media:description type=\"plain\">"
     + "I gave a bad toast at my friend's wedding. Maybe"
     + "</media:description>"
     + "<media:category"
     + " scheme=\"http://gdata.youtube.com/schemas/2007/categories.cat\">People"
     + "</media:category>"
     + "<media:keywords>toast, wedding</media:keywords>"
     + "</media:group>"
     + "</entry>";

StringBuilder sb = new StringBuilder();
sb.append("--");
 sb.append("Content-Type: application/atom+xml; charset=UTF-8"); 
sb.append(entry);
 sb.append("--");
 sb.append("Content-Type: video/3gpp");
sb.append("Content-Transfer-Encoding: binary");

               String bodyStart = sb.toString();

               File file = new File("/mnt/sdcard/recordvideooutput.3gpp");
               FileInputStream fIn = new FileInputStream(file);
               byte fileBytes[] = new byte[(int) file.length()];
               fIn.read(fileBytes);

            HttpClient client1 = new DefaultHttpClient();
            HttpPost post1 = new HttpPost("https://uploads.gdata.youtube.com/feeds/api/users/default/uploads");


            List<NameValuePair> pairs1 = new ArrayList<NameValuePair>();
            pairs1.add(new BasicNameValuePair("X-GData-Key", "key=xxxxx"));
            pairs1.add(new BasicNameValuePair("Slug", "/mnt/sdcard/recordvideooutput.3gpp"));
            pairs1.add(new BasicNameValuePair("Content-Type", "application/atom+xml; charset=UTF-8"));
            pairs1.add(new BasicNameValuePair("Content-Length", "" + (bodyStart.getBytes().length + fileBytes.length)));
            pairs1.add(new BasicNameValuePair("Authorization", "GoogleLogin " + auth));


post1.setEntity(new UrlEncodedFormEntity(pairs1));

response = client1.execute(post1);
  • 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-05-27T17:42:05+00:00Added an answer on May 27, 2026 at 5:42 pm

    You can convert API to google code for an android application. This link may be useful for you
    Resources for Mobile Development with YouTube

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

Sidebar

Related Questions

I am trying to upload video from the iPhone application using FBConnect. Actually I
I'm working on a web application import program. Currently an admin user can upload
I am working on a struts 2 web application where user can upload file
I'm working on an application where users upload a video and play it back
I am working on a web application that allows users to upload attachments. These
I am working on a Django application which allows a user to upload files.
I am working on splitting out an existing, working application that I currently have
I have pretty much finished my first working Symbian application, but in my hastened
Now that I have a read-only application working, I am working on the insert
My application was working fine but I don't know how suddenly allow_url_fopen set OFF

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.