简体   繁体   English

错误Volley库com.android.volley.ParseError:org.json.JSONException:

[英]ERROR Volley Library com.android.volley.ParseError: org.json.JSONException:

I try to do a PUT request using Volley Library. 我尝试使用Volley Library发出PUT请求。 I already did get request and put request usin g Override methode getParam() , but for this request i need to send a jsonOjbect that i created before. 我已经获得了请求,并使用了覆盖方法getParam()来放置请求,但是对于此请求,我需要发送我之前创建的jsonOjbect。

But in the response i have : 但是在响应中,我有:

08-25 09:44:34.638: I/ViewPdf:  SaveDataToProxy ERROR(8512): 
error: com.android.volley.ParseError: org.json.JSONException: Value <br of type 
java.lang.String cannot be converted to JSONObject

So this is my method connection : 这是我的方法连接:

public void SaveDataToProxy(JSONObject jsonObject){

    // Tag used to cancel the request
    String tag_json_obj = "json_obj_req";

    String url = Properties.getUrl_proxy() + ":" + Properties.getPort_proxy() +"/api/points/"+this.id_point;
    Log.i("url",url); 

    final ProgressDialog pDialog = new ProgressDialog(this);
    pDialog.setMessage("Loading...");
    pDialog.show(); 

    JsonObjectRequest jsObjRequest = new JsonObjectRequest
    (
            Request.Method.PUT, url, jsonObject, new Response.Listener<JSONObject>()
            {
                @Override
                public void onResponse(JSONObject response)
                {
                        Log.i(TAG + ":  SaveDataToProxy SUCCESS", "response: " + response);
                }

            }, new Response.ErrorListener() 
            {
                @Override
                public void onErrorResponse(VolleyError error) 
                {
                    Log.i(TAG + ":  SaveDataToProxy ERROR", "error: " + error);
                }
             }
    )

    {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError 
        {
            HashMap<String, String> headers = new HashMap<String, String>();
            headers.put("Content-type", "application/json");

            return headers;
        }
    };

    AppController.getInstance().addToRequestQueue(jsObjRequest, tag_json_obj); 
}

and this is the JSONObject.toString() that i send : 这是我发送的JSONObject.toString():

{
"depositProduct": [
    null
],
"collectionProduct": [
    null
],
"status": 1,
"end_hour": "04:00:00",
"type": "COLLECTION",
"id": 1,
"collector": "{\"address\":\"14 Rue de la serviellier\",\"city\":\"Germs-sur-l\\u0027oussouet\",\"fax\":\"0380910303\",\"zip_code\":\"65451\",\"transit_date\":\"2014-08-25 00:00:00\",\"name\":\"Jeanjean\",\"tel\":\"0643665316\",\"siret\":\"73282932000074\",\"weight\":0.0,\"volume\":0.0,\"id_erp\":20,\"point_id\":1,\"quantity\":0,\"id\":1}",
"closed_client": false,
"id_erp": 111,
"miscellaneous": "inf test2",
"infos": "test tablette",
"downtime": "2",
"form_type": "cerfa11352_02",
"sequence": 1,
"producer": "{\"address\":\"207 rue charles de gaulle\",\"city\":\"Montbard\",\"email\":\"Dupond.patrick@gmail.com\",\"fax\":\"0380954609\",\"zip_code\":\"21500\",\"id_erp\":\"C10018-1\",\"name\":\"Foyer mutualisteZZ\",\"waste_code\":\"215004\",\"waste_adr\":\"un 3291 Dechet d\\u0027hopital non specifie, NSA, 6.2II\",\"signature\":\"/mnt/sdcard/tour_1/point_1/producer_1.png\",\"siret\":\"73282932000074\",\"tel\":\"0380915454\",\"transit_date\":\"2014-08-25 00:00:00\",\"volume\":0.0,\"weight\":0.0,\"point_id\":1,\"quantity\":0,\"id\":1}",
"no_waste": false,
"factory": "{\"address\":\"Usine d\\u0027incineration les bouillots\",\"city\":\"Bayet\",\"fax\":\"0470456168\",\"zip_code\":\"03500\",\"name\":\"LUCANE\",\"tel\":\"0470454857\",\"siret\":\"97596145524658\",\"signature\":\"/mnt/sdcard/tour_1/point_1/factory_1.png\",\"refusal_support_reason\":\"0\",\"weight\":0.0,\"volume\":0.0,\"point_id\":1,\"operation_type\":0,\"id_erp\":31,\"quantity\":0,\"refusal_support\":0,\"id\":1}",
"id_tour": 1,
"begin_hour": "06:00:00",
"internal_error": false
}

i hope that you will can help me =) 我希望你能帮助我=)

EDIT 1 : This is my full stack trace , we can see just the connection , and nothing of very important... 编辑1:这是我的完整堆栈跟踪,我们只能看到连接,而没有什么很重要的...

08-25 10:21:03.106: D/Volley(29845): [195] BasicNetwork.logSlowRequests: HTTP response   for request=<[ ]
 http://192.168.0.60:80/api/points/1 0x6768b5f7 NORMAL 5>
 [lifetime=6891],   [size=7531], [rc=200], [retryCount=1]
08-25 10:21:03.106: I/ViewPdf:  SaveDataToProxy ERROR(29845): error:    com.android.volley.ParseError: org.json.JSONException: Value <br of type java.lang.String   cannot be converted to JSONObject
08-25 10:21:03.106: D/Volley(29845): [1] Request.finish: 6894 ms: [ ]     http://192.168.0.60:80/api/points/1 0x6768b5f7 NORMAL 5

This is not your problem this is server side problem, the server dose not return valid json to you. 这不是您的问题,这是服务器端的问题,服务器不会向您返回有效的json it actually returns you html code, in order to see what exactly it returns just install add on for broswer for example RESTClient for mozilla and send your request to the server by corresponding type(post-get-...) then see server result. 它实际上会返回您的html代码,以查看其返回的确切内容,只需为浏览器安装add on,例如RESTClient for mozilla并将您的请求按相应的类型(post-get -...)发送到服务器,然后查看服务器结果。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JSON Volley 嵌套 JSON 数组 com.android.volley.ParseError: org.json.JSONException - JSON Volley Nested JSON Array com.android.volley.ParseError: org.json.JSONException E/Volley: com.android.volley.ParseError: org.json.JSONException: Value {&quot;results&quot;:[{ - E/Volley: com.android.volley.ParseError: org.json.JSONException: Value {"results":[{ E/排球:com.android.volley.ParseError:org.json.JSONException - E/Volley: com.android.volley.ParseError: org.json.JSONException com.android.volley.parseerror org.json.json异常值类型为java.lang.String的无法转换为JSONObject - com.android.volley.parseerror org.json.jsonexception value yes of type java.lang.String cannot be converted to JSONObject com.android.volley.ParseError: org.json.JSONException: Value 0 of type java.lang.Integer cannot be converted to JSONObject - com.android.volley.ParseError: org.json.JSONException: Value 0 of type java.lang.Integer cannot be converted to JSONObject Volley解析错误org.json.JSONException:输入的结束字符为0 - Volley parse Error org.json.JSONException: End of input at character 0 of 如何在Volley上修复org.json.JSONException: - How to fix org.json.JSONException: on Volley? com.android.volley.parse错误java.lang.string类型的org.json.jsonexception值无法在Android Volley中转换为jsonArray - com.android.volley.parse error org.json.jsonexception value of type java.lang.string cannot be converted to jsonArray in Android Volley 解析有效JSON时Volley org.json.JSONException - Volley org.json.JSONException when parsing valid JSON 把不工作在 android Volley org.json.JSONException: End of input at character 0 of - put not working on android Volley org.json.JSONException: End of input at character 0 of
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM