1
美好的一天,一直在挣扎了一下,不知道该怎么办了。我正在使用Android Asynchronus Http Library here发送POST解析,但我不断收到此错误消息。错误的内容类型错误时,发布到Parse.com RestAPI
{"code":107,"error":"This endpoint only supports Content-Type: application/json requests, not application/x-www-form-urlencoded."}
这里是我的代码的相关部分:
client = new AsyncHttpClient();
client.addHeader("Content-Type", "application/json");
client.addHeader("X-Parse-Application-Id", context.getResources().getString(R.string.app_id));
client.addHeader("X-Parse-REST-API-Key", context.getResources().getString(R.string.rest_api_key));
RequestParams params = null;
JSONObject json = new JSONObject();
try {
json.put(NAME, player_text.getText().toString());
json.put(CLUB, club_text.getText().toString());
} catch (JSONException e) {
e.printStackTrace();
}
params = new RequestParams("json",json); //takes a key value pair
client.post(context, url, params, responsehandler); // posting to https://api.parse.com/1/classes/ABCDER/
我已经设置页眉内容类型应用程序/ JSON,所以我不知道为什么我收到错误。我也请求PARAMS中的getContentType来看,它给了我PARSE抱怨的错误。我可能做错了什么?任何帮助都很受赞赏。在此先感谢
谢谢!对不起,我不在,无法提前回复。 – irobotxxx