Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
houdinisparks opened this issue Apr 5, 2018 · 0 comments

Comments

@houdinisparks
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant