私のAPIと対話しようとしていますが、アプリはリクエストを送信しません:
var connectToAppbis = {
login: function(login, password) {
var params = {
"login": login,
"password": password
};
var url = "http://api.city1.fr/idstock/dev/v3/index.php/auth";
var client = Ti.Network.createHTTPClient({
// function called when the response data is available
onload : function(e) {
Titanium.API.info(this.responseText);
var json = JSON.parse(this.responseText);
},
// function called when an error occurs, including a timeout
onerror : function(e) {
Ti.API.debug(e.error);
alert('error');
},
timeout : 5000 // in milliseconds
});
// Prepare the connection.
client.setRequestHeader("Content-Type", "application/json; charset=utf-8");
client.open("POST", url);
// Send the request.
client.send(JSON.stringify(params));
}
};
私はマニフェストに許可を追加しましたJSON.stringify()
。何かを含めるべきですか?オンだからhttp://api.city1.fr/idstock/dev/v3/index.php/auth
期待通りのJSON値を取得しました...
エラー ログ:
[ERROR] : TiHttpClient: (TiHttpClient-1) [15666,15666] HTTP Error (org.apache.http.client.HttpResponseException): Not Found
[ERROR] : TiHttpClient: org.apache.http.client.HttpResponseException: Not Found
[ERROR] : TiHttpClient: at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:275)
[ERROR] : TiHttpClient: at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:219)
[ERROR] : TiHttpClient: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:974)
[ERROR] : TiHttpClient: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:954)
[ERROR] : TiHttpClient: at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1334)
[ERROR] : TiHttpClient: at java.lang.Thread.run(Thread.java:864)