0

I use the SFDC mobile sdk for android, and i can't get the server error response details (only 400 error) which is limited,

public void sfInsert(final Context context, final RestClient client, final Activity launcherActivity) throws UnsupportedEncodingException, IOException, JSONException {
    RestRequest restRequest;
    String api = context.getResources().getString(R.string.api_version);
    if(Util.isNull(getId())) {
        restRequest = RestRequest.getRequestForCreate(api, "DRX__c", ModelsUtils.getHashMap(this.asJSONObject(), doNotInsert));

    client.sendAsync(restRequest, new AsyncRequestCallback() {

        @Override
        public void onSuccess(RestRequest request, RestResponse response) {
            Util.toast("Insert success !");
                            // success case 
        }

        @Override
        public void onError(Exception e) {
                            /**
                            * HERE : rather than saying Insert error,i'd rather show the user the actual error happening in the server (validation rules, data privacy issues and so on.
                            */
            Util.toast("Insert error.");
            e.printStackTrace();
        }
    });
} 

rather than saying Insert error,i'd rather show the user the actual error happening in the server (validation rules, data privacy issues and so on.

1 Answer 1

0

Finally i figured out how, In the onError method add the following:

`@Override
public void onError(Exception e) {
    VolleyError volleyError = (VolleyError) e;
    NetworkResponse response = volleyError.networkResponse;
    String json = new String(response.data);
    Log.d(json);
}`

The json string contains the Force.com server errors that you can display to the user.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .