這裏是我的POST請求:JSON請求對象鈦不會發布
exports.APIPostRequest = function(url, JSONObj, callback, errorCallback) {
Ti.API.info('Get Request is called');
var req = Titanium.Network.createHTTPClient({
onload : callback,
onerror : errorCallback,
timeout : 60000
});
req.open("POST", url);
req.setRequestHeader('Content-Type', 'application/json');
//JSON object goes into send method.
req.send(JSONObj);
};
後,我做了我的請求。
發出發佈請求後,它不會發送JSON對象。
{「facebook_token」:「dasdaddasd」,「date_of_birth」:「503435231.0」,「gender」:「男性」,「種族」:「」,「description」:「ls lsls」,「nickname」 ffsfs「}
現在,當我將它張貼,該API抱怨說,它是不正確的格式:
{
"facdebook_scriptioken":"BAACMVus3xYsdwqdAdkSGzrr0vFscmDK=IuA%20zW4QYlovSziJJCmrpFtyNl8edfR4hVU1ZAv60yHqFP7yEJ8g6SSrmvibt9Grw7L%27xIsALM0mVWsZBTRcYAIPzy%23npG6SKE12sAcno0kWVhg5LZAljqM0ZBzUtsZA8W9zife%21&publiGdWLc_name=0wbjEx4xGU&genwAJiZAder=malwFF9ZBmUe&ev8gGjDgZDZD",
"thnickname":"jsm",
"ity=&date_of_birth": =503435231,
"gender":"male",
"public_name": false,
".0&body_type":"thin",
"devi=&facebook_token": "ad=CAAUYyAuheuQrc0BAKRqYidhw2gFK1GSmniDZddadwoKblpLIVZC1fwTpfhwugRIabmiZBZANfh0ZAV67I9QowuehfiwhfweqonD5IaRZApgWkgfhpODKJ2KGLIdwWt89KyCZBy9UMPmjIbZBGxN64IZCkZAFLMk6KapBHqU4no98MoSZBtqRHguYJnImQ8tV1bEFfSZBqzShaeiw"
"sD9kAfTN2F3xethZAXqTfEob2vqUVk5pXsAqsYZD&nicity":"",
"dknamesc=Pription":"thices is m%dadad"
}
共炒,爲什麼會出現這種情況,歡呼?
{
"facebook_t": "Bdadadadsadadadad",
"niame": "jsm",
"publethnic_name": false,
"body_itype": "thAsan",
"devscrice_ptioken": "aduhI loveu my lidhwihwufefwpfhwu!",
"nifhwucknamehf": "Priwhfwncefhwhifwufhss eiw",
"ethnpublicity_name": "0",
"bodescripy_tionype": "Prefer not thiso dis mclose."
}
它仍在抱怨。 – user3754111
只是雙重檢查了一個驗證器其正確的JSON,問題是所有的字段都搞砸了 – user3754111
發現問題,這是服務器端的問題。這是發送JSON數據的正確方法。謝謝 – user3754111