Skip to content

parseError post message #579

Open
Open
@eduardofp90

Description

@eduardofp90

I have this code and I have always the same error "onError errorDetail : parseError". I have tried to send a simple JSON but it doesn't work. What could be the problem the problem in the code?

btn_ok_mois.setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View view) {
//POST JSON MOIS
JSONObject jsonObjectMOIS = new JSONObject();
try {
String valueMinMois = et_min_mois.getText().toString();
int finalvalueMinMois = Integer.parseInt(valueMinMois);
jsonObjectMOIS.put("minMois", finalvalueMinMois);
String valueMaxMois = et_max_mois.getText().toString();
int finalvalueMaxMois = Integer.parseInt(valueMaxMois);
jsonObjectMOIS.put("maxMois", finalvalueMaxMois);

            } catch (JSONException e) {
                e.printStackTrace();
            }
            AndroidNetworking.initialize(getApplicationContext());

            AndroidNetworking.post("https://example.com")
                    .addJSONObjectBody(jsonObjectMOIS ) // posting json
                    .setTag("moisture")
                    .setPriority(Priority.MEDIUM)
                    .build()
                    .getAsJSONObject(new JSONObjectRequestListener() {
                        @Override
                        public void onResponse(JSONObject response) {
                            // do anything with response
                            Toast.makeText(Thresholds.this,"OK",Toast.LENGTH_SHORT).show();
                            //tv_test.setText(response.toString());
                        }
                        @Override
                        public void onError(ANError error) {
                            // handle error
                            Toast.makeText(Thresholds.this,"ERROR",Toast.LENGTH_SHORT).show();
                            if (error.getErrorCode() != 0) {
                                Log.d(TAG, "onError errorCode : " + error.getErrorCode());
                                Log.d(TAG, "onError errorBody : " + error.getErrorBody());
                                Log.d(TAG, "onError errorDetail : " + error.getErrorDetail());

                            } else {
                                // error.getErrorDetail() : connectionError, parseError, requestCancelledError
                                Log.d(TAG, "onError errorDetail : " + error.getErrorDetail());
                            }
                        }
                    });
        }
    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions