REST API + Dispatch (Scala)

124 views
Skip to first unread message

loadedlux

unread,
Nov 4, 2012, 11:07:06 PM11/4/12
to orient-...@googlegroups.com
Has anyone tried to combine dispatch 0.9.3 and the REST API ..

I am having trouble posting data to my orientdb server. It does work with curl so I know the problem does not lie with the REST API. I would just like to know if anybody has any insight on the 505 error or the exception raised on the server.

Response DefaultHttpResponse(chunked: false)
HTTP/1.1 505 Error on executing of POST for the resource: /document/restTest
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Date: Sun Nov 04 22:55:56 EST 2012
Content-Type: text/plain; charset=utf-8
Server: OrientDB Server v.1.2.0 (build @BUILD@)
Connection: Keep-Alive
Content-Length: 30

Request DefaultHttpRequest(chunked: false)
POST /document/restTest HTTP/1.1
Host: localhost:2480
Connection: keep-alive
Accept: */*
User-Agent: NING/1.0
Content-Length: 61

Server.sh throws ...

java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:150)
    at java.net.SocketInputStream.read(SocketInputStream.java:121)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
    at com.orientechnologies.orient.enterprise.channel.text.OChannelText.read(OChannelText.java:57)
    at com.orientechnologies.orient.server.network.protocol.http.ONetworkProtocolHttpAbstract.readAllContent(ONetworkProtocolHttpAbstract.java:329)
    at com.orientechnologies.orient.server.network.protocol.http.ONetworkProtocolHttpAbstract.execute(ONetworkProtocolHttpAbstract.java:518)
    at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:43)

scala code ...

val uri = url("http://localhost:2480/document/restTest").as(username, pwd)      
executer(uri.POST.setBody("{\"@class\":\"User\",\"name\":\"Ant Jones\",\"email\":\"An...@email.com\"}"))

I was able to use dispatch 0.9.3 to create a class on my server instance using

protected lazy val executer = new Http
val reqHost = url("http://localhost:2480/class/restTest/Track").as_!(username, pwd)
executer(reqHost.POST)

Luca Garulli

unread,
Nov 7, 2012, 7:36:48 PM11/7/12
to orient-database
Hi,
seems that something is needed. Probably just flush or last \n?

Lvc@



--
 
 
 

loadedlux

unread,
Nov 11, 2012, 5:58:52 PM11/11/12
to orient-...@googlegroups.com
in case anyone goes this route ..

reqHost.POST.setBody(jsonDoc).setHeader("Content-Type", "application/x-www-form-urlencoded"))

the setHeader being the part that was missing

Luca Garulli

unread,
Nov 11, 2012, 7:37:04 PM11/11/12
to orient-database
Hi,
thank you. This has been indexed by Google for the further Scala users ;-)

Lvc@


--
 
 
 

Reply all
Reply to author
Forward
0 new messages