Java HttpURLConnection OutputStreamWriter is empty -


i know has been answered 10,000+ times. have been reading , testing recommendations on hour without progress.

in code below, request body empty.

url url = new url("[removed]"); httpurlconnection conn = (httpurlconnection)url.openconnection(); conn.setrequestproperty("authorization", "bearer [removed]"); conn.setrequestmethod("post"); conn.setrequestproperty("content-type","application/json"); conn.setdooutput(true); conn.setdoinput(true); outputstreamwriter writer = new outputstreamwriter(conn.getoutputstream()); writer.write("abc"); writer.flush(); writer.close();  string line; bufferedreader reader = new bufferedreader(new                               inputstreamreader(conn.getinputstream())); while ((line = reader.readline()) != null) {   system.out.println(line); }  reader.close(); 

the record created on server, body null.

any appreciated.

the exact same code not work on localhost works on app engine. don't understand why, code above works.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -