How to make Patch Request to server on Android

ANDROID SERVER 300516 1
Social sharing

What’s a Patch request?
On Android, we generally use 4 types of HTTP requests during server side communication; POST, GET, PUT and DELETE. PATCH isn’t one of them. It requests a set of changes described in the request entity to be applied to the resource identified by the Request-URI. You can use this in case you want to update only one field of a resource; saving bandwidth compared to using the PUT request.

Code snippet:

JsonObjectRequestpatchRequest = new JsonObjectRequest(Request.Method.POST,url, jsonObject,
newResponse.Listener<JSONObject>()
                {
                    @Override
public void onResponse(JSONObject response) {
                        // display response
                      //  Log.d("Response", response.toString());                     

                    }
                },
newResponse.ErrorListener()
                {
                    @Override
public void onErrorResponse(VolleyError error) {
Log.d("Error.Response", error.getMessage());


                    }
                }
        ){
            @Override
public Map<String, String>getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("X-HTTP-Method-Override","PATCH");
headers.put("Content-Type","application/json");
return headers;
            }
        };
MyApplication.getInstance().getRequestQueue().add(patchRequest);

We, at Andolasoft are experts in developing glitch free, seamless & cost-effective Android apps. If you have an idea, please share to us and let’s have a talk to take it from there.

Also, please share your suggestions below.

Your recently viewed posts:

    Contact Us

    We’d love to help & work with you




    When do you want to start ?


    Enter your email address to stay up to date with the latest news.
    Holler Box

    Orange Exit pop up

    Subscribe for the latest
    trends in web and
    mobile app development
    Holler Box

    Exit pop up

    Sad to see you leaving early...

    From "Aha" to "Oh shit" we are sharing everything on our journey.
    Enter your email address to stay up to date with the latest news.
    Holler Box