私の問題は、リクエストを正しく作成したと信じているのに、[400 {"メッセージ":"JSON 解析の問題"}] が発生することです。
ここに私のコードがあります:
var xhr = Ti.Network.createHTTPClient({
onload : function() {
Ti.API.debug(this.responseText);
json = JSON.parse(this.responseText);
callback(json);
},
onerror : function(e) {
alert('error!');
Ti.API.info(e.error + " " + this.status + " " + this.responseText);
}
});
xhr.validatesSecureCertificate = true;
xhr.open("POST", "https://api.github.com/authorizations");
xhr.setTimeout(10000);
authstr = 'Basic ' + Titanium.Utils.base64encode(User.username + ':' + User.password);
xhr.setRequestHeader('Authorization', authstr);
xhr.send({username: User.username, password: User.password});