Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2208] Android: HTTPClient POST is not working

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-08-22T23:00:19.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAlloy, Titanium SDK & CLI
Labelsandroid
ReporterBraden Powers
AssigneeMauro Parra-Miranda
Created2013-08-16T14:05:58.000+0000
Updated2016-03-08T07:41:12.000+0000

Description

I have been trying to connect to my remote server and it works correctly in iOS but not in Android. This is the code:
var params = {
	username : 'yourUserName',
	password : 'yourPassWord'
};
var url = "http://www.google.com/";

var xhr = Ti.Network.createHTTPClient({
	onload : function(e) {
		Ti.API.debug(this.responseText);
		alert('success');
	},
	onerror : function(e) {
		Ti.API.debug(e.error);
		alert('error');
	},
	timeout : 5000,
});

xhr.open("POST", url);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(params);

Comments

  1. Stephen Feather 2013-08-16

    #1 The JIRA is for reporting verified, use case backed problems with the platform. This should be in the Q&A if you are a community level user, or in the help desk of enterprise. #2 Since we KNOW that httpclient works on android, this is NOT a verified problem with the platform. #3 You have two onerror/timeout declarations, and while the second should overwrite the first, it leads me to question your programming skills as you have posted pretty dirty code. #4 There is not enough information to produce a test case. Ticket should be closed. #5 httpClient works for me. Ticket should be closed.
  2. Braden Powers 2013-08-22

    I have confirmed by going through different versions of the Titanium SDK that it does work with 3.1.0 and actually stopped working in 3.1.1.
  3. Daniel Sefton 2013-08-22

    Hi Braden, I have changed the test case to have valid syntax. You're welcome to try it again. Ideally we will need your server URL (and code) to be able to reproduce the issue. Also please state your Ti SDK version. Thanks.
  4. Daniel Sefton 2013-08-22

    Can you try it with 3.1.2 as well?
  5. Braden Powers 2013-08-22

    Sorry syntax was a mess. I did confirm it didn't work with 3.1.2 as well.
  6. Braden Powers 2013-08-22

    The server is running drupal 6.0 using hte 3.0 services module.
  7. Daniel Sefton 2013-08-22

    There is also a similar report at TC-2501. But it's hard for us to know the problem without being able to reproduce it. It looks like a server specific issue, but it's interesting that you're seeing a regression between 3.1.0 and 3.1.1. I might escalate TC-2501 and we can go from there.
  8. Mauro Parra-Miranda 2013-11-24

    DUP TIMOB-14939

JSON Source