http - use Java client like curl with param -


i use influxdb 0.9. in version, can write database like

curl -xpost 'http://localhost:8086/write?db=mydb' -d 'cpu,host=server01,region=uswest value=1.0' 

now convert java

url url = new url("http", "localhost", 8086, "/write?db=mydb"); httpurlconnection con = (httpurlconnection) url.openconnection(); con.setrequestmethod("post"); con.setdooutput(true); outputstream wr = con.getoutputstream(); stirng s = "cpu,host=server01,region=uswest value=51.0"; wr.write(s.getbytes(utf_8)); wr.flush(); wr.close(); 

but doesn't work. "-d" meant represent post parameters? how can express in java?

in example curl flag should --data-binary, not -d, can have different encoding. long string unaltered java code should fine. url encoding prevent line protocol insert working.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -