F
F
freecats2017-03-18 23:30:27
Android
freecats, 2017-03-18 23:30:27

How to send a PUT request with ANDROID cookies?

I'm trying to send a PUT request to the server and attach cookies. The cookie server does not see, throws out for authorization. Through the Advanced REST client everything is fine, the request goes away. POST request also leaves normally cookies leave.
Code below

URL url1 = new URL("http://admin.carex.su/supplier_order_items/10117/add_income?qnt=1");
                HttpURLConnection con2 = (HttpURLConnection) url1.openConnection();
                con2.setRequestMethod("PUT");
                con2.setRequestProperty("Cookie", mSettings.getString(APP_PREFERENCES_COOKIE, ""));
                con2.setRequestProperty("Content-Type", "application/json; charset=utf-8");
                con2.setRequestProperty("_method", "PUT");
                con2.setInstanceFollowRedirects(false);
                con2.connect();
                int responseCode1 = con2.getResponseCode();
                System.out.println("\nSending 'GET' request to URL : " + url1);
                System.out.println("Response Code : " + responseCode1);

                BufferedReader in1 = new BufferedReader(
                        new InputStreamReader(con2.getInputStream()));
                String inputLine1;
                StringBuffer response1 = new StringBuffer();

                while ((inputLine1 = in1.readLine()) != null) {
                    response1.append(inputLine1);
                }
                in1.close();
                con2.disconnect();

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2018-01-12
@qonand

Design patterns are designed to solve specific problems and not just to make things beautiful. In the question you do not describe what problem you are trying to solve. What exactly is the problem? Do you know how to set the camera type when the class is created? Doesn't know how best to manage camera types? (and what is a type and how it is represented in your library is not clear

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question