DWorkS / VolleyPlus

🏐 Volley library : make everything faster . Its an improvements for Volley by Google for Android https://android.googlesource.com/platform/frameworks/volley
https://github.com/DWorkS/VolleyPlus
984 stars 275 forks source link

Android VolleyPlus SimpleMultipartRequest sending a POST request instead of the PUT request specified #72

Open houdinisparks opened 6 years ago

houdinisparks commented 6 years ago

I am trying to send a PUT SimpleMultipartRequest from my android to a AWS Lambda + API Gateway serverless api I have configured. The request sends, however it is received as a POST request instead of a PUT request at the aws endpoint, which is not expected. I can't figure out why it is sending a POST request when I have already instantiated the SimpleMultipartRequest with a PUT method as per my code:

`String url = BASEURL + "/person"; RequestQueue requestQueue = Volley.newRequestQueue(applicationContext);

SimpleMultiPartRequest simpleMultiPartRequest = new SimpleMultiPartRequest(
        Request.Method.PUT, url, new Response.Listener<String>() {
    @Override
    public void onResponse(String response) {

        Toast.makeText(applicationContext, "response received: \n" +
                response, Toast.LENGTH_LONG).show();

        JSONObject jsonObject;
        boolean success = false;

        try {
            jsonObject = new JSONObject(response);
            if (jsonObject.get("response").equals("ok")) {
                success = true;
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
},
        new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

            }
        });

simpleMultiPartRequest.addStringParam("id", person.getId());
simpleMultiPartRequest.addStringParam("name", person.getName());
simpleMultiPartRequest.addStringParam("persongroupid", person.getPersonGroupID());

for (String filepath :
        person.getImageFilepaths()) {
    simpleMultiPartRequest.addFile("images", filepath);
}
requestQueue.add(simpleMultiPartRequest); `

and then on the log outputs in AWS it is received as such:

[INFO] 2018-04-04T03:44:58.366Z 8b616230-37ba-11e8-804e-affb97009f27 119.56.103.169 - - [04/Apr/2018:03:44:58 +0000] "POST /api/v1/person HTTP/1.1" 200 121 "" "Dalvik/2.1.0 (Linux; U; Android 7.0; VKY-L29 Build/HUAWEIVKY-L29)" 0/670.415

I am sending from a huawei phone as you can see from the logs. If I send a PUT request using POSTMAN, the server will reply as expected, so I dont think this is a server-side problem.