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.

  • Well, it also says: an internal server error, and you show the client code. Code php show - BOPOH
  • The problem is that I have a server part, but in php I do not understand anything. Get requests, by the way, correctly return JSON. - Sasha Vitalev
  • What is in the web server error logs? In the logs of Laravel? - Dmitriy Simushev
  • that is, it is an internal server error, what needs to be asked from the server developer what is wrong. - Vladyslav Matviienko

0