[AC-2782] HTTPClient will not send a POST HTTP request
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2011-08-10T02:19:34.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | Keith Miller |
Assignee | Tony Guntharp |
Created | 2011-07-24T20:32:58.000+0000 |
Updated | 2016-03-08T07:47:41.000+0000 |
Description
All requests coming to the server from HTTPClient are GET requests, no matter what I set it to.
Here is the code:
var request = Titanium.Network.createHTTPClient();
request.open('POST', "http://test.com");
request.onload = function() {
try {
var content = JSON.parse(this.responseText);
if(content.error == undefined) {
// do some things
} else {
alert(content.error);
}
} catch (err) {
Titanium.API.error(err);
Titanium.UI.createAlertDialog({
message : err,
title : "Remote Server Error"
});
}
};
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
request.send({ test: 'test'});
I've also tried not setting the header and also passing in the data as a string instead of an object.
Attachments
File | Date | Size |
---|---|---|
android.log | 2011-07-25T08:17:14.000+0000 | 4246 |
app.js | 2011-07-25T08:17:14.000+0000 | 765 |
iphone.txt | 2011-07-25T08:17:14.000+0000 | 1820 |
Keith The information listed in the environment section seems to imply that you have observed this issue for both mobile AND desktop apps. As I'm able to successfully send POST requests for my own mobile projects, I'd be surprised if that is the case. Please explicitly state whether this relates to iPhone or Android. You need to provide a proper [usecase](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-CreatingGoodUsecases), which is concise code that demonstrates the issue and runs without modification when pasted into an app.js file. You also should consult the community via a Q&A question before raising a ticket. Please provide the link to that question. Please read the [Jira Ticket Checklist](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-Summary%3AJiraTicketChecklist) to help you correct this ticket, and before raising any more. Thanks
Also, please provide the log of the failed request. Thanks
Sorry about that. I marked the component as Mobile, since I'm only using Titanium Studio for mobile development. It is happening in both the iPhone and Android, emulators and the actual phones. I also cleaned the project's build directory. I have attached both the app.js and the log files for when this happens. Here is the Q&A link: http://developer.appcelerator.com/question/123135/httpclient-will-not-send-a-post-http-request#comment-91925 This code seems to work fine for other people, so it seems like a weird bug that it's not working for me. How can I see the actual request the code is sending? Thanks.
So, the following code works:
So weird. At least it's working now.
Great work, Keith, glad you fixed it. You can inspect the network traffic using a protocol analyzer, such as [Wireshark](http://www.wireshark.org/). Cheers
User confirmed problem was with code.
Closing due to inactivity.