Unexpected response code 500 for POST method

后端 未结 4 1042
甜味超标
甜味超标 2020-11-30 09:17

I am doing an update on the old project & I don\'t have much knowledge of Android as of now. In project we have Comments section on product.

For comment after se

相关标签:
4条回答
  • 2020-11-30 09:38

    Try to change php file permission to 755.

    0 讨论(0)
  • 2020-11-30 09:39

    The problem is below.

    final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(
        Method.POST,
        act.getString(R.string.CommentForUserURL),
        null, new Response.Listener<JSONObject>() {
        ^^^^
    

    It should be

    final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(
        Method.POST,
        act.getString(R.string.CommentForUserURL),
        new JSONObject(params), new Response.Listener<JSONObject>() {
        ^^^^^^^^^^^^^^^^^^^^^^
    

    Copy code from protected Map<String, String> getParams() before final JsonObjectRequest.

    That's it!!!

    Reason is as below.

    The JsonObjectRequest is extended JsonRequest which override getBody() method directly, so your getParam() would never invoke, I recommend you extend StringRequest instead of JsonObjectRequest.

    your can check this answer for more details.

    0 讨论(0)
  • 2020-11-30 09:50

    Actually 500 means Internal server error and this is caused by the Rest-api you are calling and not due to Volley,so check the back-end code.

    0 讨论(0)
  • 2020-11-30 10:00

    Check your value small capital letter issue ,your server which format accept value from your end.

    0 讨论(0)
提交回复
热议问题