A
A
afna2015-06-16 11:49:05
Java
afna, 2015-06-16 11:49:05

How to get cookie for post request?

I implement the following Post-zaros:

url = new URL(url_str);
con = (HttpURLConnection) url.openConnection();
con.setRequestProperty("Content-type", "application/json; charset=utf-8");
con.setRequestProperty("Accept-Charset", "UTF-8");
con.setRequestProperty("Accept", "*/*");
con.setRequestProperty("Accept-Encoding", "gzip");
con.setRequestProperty("User-Agent:", "Android 4.0+");
con.setDoOutput(true);
con.setDoInput(true);
con.setConnectTimeout(13000);
con.setReadTimeout(11000);
con.connect();
Map<String, List<String>> map = con.getHeaderFields();
        for (Map.Entry<String, List<String>> entry : map.entrySet()) {
            System.out.println("Key : " + entry.getKey() +
                    " ,Value : " + entry.getValue());
        }
String cookie = con.getHeaderField("Set-Cookie");

con.getHeaderFields() returns null. What's wrong ?
Maybe I'm getting headers wrong?
Google didn't help.
Can you please tell me how to get the cookie correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
afna, 2015-06-16
@sulik93

The issue was resolved. Server error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question