Note that there are some explanatory texts on larger screens.

plurals
  1. POVideo upload on YouTube - Android
    primarykey
    data
    text
    <p>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?</p> <pre><code>HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("https://www.google.com/accounts/ClientLogin"); List&lt;NameValuePair&gt; pairs = new ArrayList&lt;NameValuePair&gt;(); 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 = "&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;Bad Wedding Toast&lt;/media:title&gt;" + "&lt;media:description type=\"plain\"&gt;" + "I gave a bad toast at my friend's wedding. Maybe" + "&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;toast, wedding&lt;/media:keywords&gt;" + "&lt;/media:group&gt;" + "&lt;/entry&gt;"; 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&lt;NameValuePair&gt; pairs1 = new ArrayList&lt;NameValuePair&gt;(); 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); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload