java - REST HttpURLConnection -


i working on rest client experimenting tinkerpop database using using httpurlconnection.

i trying send on 'get - connect'. understand (from net research) if use dooutput(true) 'client' 'post' if setrequestmethod 'get' post default (well ok?) when comment out the dooutput(true) error:

java.net.protocolexception: cannot write urlconnection if dooutput=false - call setdooutput(true) @ sun.net.www.protocol.http.httpurlconnection.getoutputstream(httpurlconnection.java:995) @ restcontent.handlegetconnect(restcontent.java:88)  @ restclient.main(restclient.java:42)` 

here communication code snip have tried various option setusedooutput().

//connection.setdoinput(true); connection.setusecaches (false); connection.setdooutput(true); connection.setallowuserinteraction(false);  // set method  try {     connection.setrequestmethod("get"); } catch (protocolexception e1) {     e1.printstacktrace();     connection.disconnect(); } 

exception @ connection.setrequestmethod("get") in other case. hints?

following code works fine: url rest url supported operation.

    httpurlconnection connection = (httpurlconnection) url.openconnection();     connection.setrequestmethod("get");     //connection.setdooutput(true);     inputstream content = (inputstream) connection.getinputstream();     bufferedreader in = new bufferedreader(new inputstreamreader(content));     string line;     while ((line = in.readline()) != null) {         system.out.println(line);     } 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -