android - HttpsURLConnection setDoOutput(true) isn't working -


so writing android app tweets particular user, using twitter's 1.1 application-only-auth, requires post http request bearer token. have method set uses httpsurlconnection open connection, but

  • conn.setdooutput(true); method isn't working
  • conn.dooutput stays false
  • the request stays default get.

am doing wrong?

this method called in asynctask's doinbackground() method:

public string getrequestbearertoken(string endurl) throws ioexception {     string encodedcred = encodekeys("api-key", "api-secret");     httpsurlconnection connection = null;     try {         url url = new url(endurl);         connection = (httpsurlconnection) url.openconnection();          connection.setinstancefollowredirects(false);         connection.setdoinput(true);         connection.setdooutput(true);          connection.setrequestmethod("post");               // post request properties             connection.setrequestproperty("host", "api.twitter.com");             connection.setrequestproperty("user-agent", getresources()                     .getstring(r.string.app_name));             connection.setrequestproperty("authorization", "basic "                     + encodedcred);             connection.setrequestproperty("content-type",                     "application/x-www-form-urlencoded;charset=utf-8");             connection.setrequestproperty("content-length", "29");             connection.setusecaches(false);              ... 


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -