I'm trying to send a request to the Post site, here's the code:
URL urlObj = null; urlObj = new URL("https://mysite"); JSONObject auth = new JSONObject(); auth.put("email", email); auth.put("password", password); auth.put("remember", remember); HttpsURLConnection conn = (HttpsURLConnection) urlObj.openConnection(); conn.setRequestMethod("POST"); conn.setRequestProperty("Connection", "Keep-Alive"); conn.setRequestProperty("Accept", "application/json"); conn.setDoOutput(true); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(auth.toString()); The site returns Internal server error. Here's what the idea should be:
POST https://mysite/auth/login HTTP/1.1 Host: mysite Connection: keep-alive Content-Length: 70 Accept: application/json, text/plain, */* Origin: https://mysite X-XSRF-TOKEN: ............. User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36 Content-Type: application/json;charset=UTF-8 Referer: https://mysite/login Accept-Encoding: gzip, deflate Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4,es;q=0.2 Cookie: _ym_uid=.....; _ym_isad=1; _gat=1; _ga=GA....; XSRF-TOKEN=....; laravel_session=.... (Dots - a lot of text of the form "G5QV0FJS3ZkMkJ2UUE9PSI") Please help me properly set up sending a post request. Laravel + Angular website.