0

私の問題は、リクエストを正しく作成したと信じているのに、[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});
4

1 に答える 1

1

私はJSON.stringifyメソッドを見逃しただけです....私の体に:P. ありがとう!

于 2012-06-26T03:44:08.437 に答える