1

Hi i am using android studio and for network call using volley api. Since it's all good to get JsonObject and String as response from network call .

Is it possible to get HttpResponse from volley api ? or any method by which we can retrieve HttpResponse ?

Since i have to use external jar, in which method i can get HttpResponse object as input parameter.

Also we are getting NetworkResponse object from volley api , can we get HttpResponse from it ?

user2021938
  • 145
  • 1
  • 1
  • 9

1 Answers1

2

Although I am not totally clear with the question or the problem you have been facing . Let me guess you want the Http response from the request and post it to server with another API call ? if this is your problem , Simple solution is to override parseNetworkResponse in makeStringReq()

StringRequest strReq = new StringRequest(Method.GET,
        Const.URL_STRING_REQ,
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                Log.d(TAG, response.toString());
                msgResponse.setText(response.toString());
                hideProgressDialog();

            }
        },
        new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                VolleyLog.d(TAG, "Error: " + error.getMessage());
                hideProgressDialog();
            }
        }) {

    @Override
    protected Response<String> parseNetworkResponse(NetworkResponse response) {
        int mStatusCode = response.statusCode;
        return super.parseNetworkResponse(response);
    }
};

// Adding request to request queue
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);

then you can post the mStatusCode to server .

if I am wrong what i guessed just let me know . **If there is a will , there is a way ** , you know :)

Wubbalubbadubdub
  • 2,415
  • 1
  • 24
  • 36
  • thanks vutka , i.e i am implemented. Just want to know from NetworkResponse object in parseNetworkResponse(...) can it's possible to convert in HttpResponse object ?? Actually external jar method take only HttpResponse object as input parameter . – user2021938 Jul 24 '16 at 13:44
  • As far as i know network response contains httpresponse code . Dont take it seriously coz i am not quite sure about it . I will let you know after doing some RND @user2021938 – Wubbalubbadubdub Jul 24 '16 at 13:48
  • thanks man for support . i will also try :) – user2021938 Jul 24 '16 at 16:56