Skip to content

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

@houdinisparks

Description

@houdinisparks

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions