Danicroque belmar Danicroque belmar - 1 year ago 44
Java Question

OrientDB http request failed...?

I'm trying to do a "POST" method in Java. I create my output with the OrientDB method like this:

"http://xxxxxxxxxxx:2480/command/mydb/sql/CREATE VERTEX V SET name = ' datoAletarorio'"

I need to use the write and flush methods to send the command.

My DB is empty with this method.
Where is my error? Here is my code:

PrintWriter out = null;
conexion = (HttpURLConnection) url.openConnection();

out = new PrintWriter(conexion.getOutputStream());

String cumuloDatos1 = "http://xxxxxxxxxxx:2480/command/mydb/sql/CREATE VERTEX V SET name = ' datoAletarorio'"


Thank in advance.


The docs says:

The command-text can appear in either the URL or the content of the POST transmission. Where the command-text is included in the URL, it must be encoded as per normal URL encoding.

So you probably have to encode the URL before sending the request:

String cumuloDatos1 = 
     "http://xxxxxxxxxxx:2480/command/mydb/sql/" +

Anyway, you should see messages in the logs for a 400 or similiar in the server, if the request isn't valid.