0

For example I want to query something like this,

>hercules= g.V().has('name','hercules')
>hercules.values()
>hercules.bothE()

How do I send those query to gremlin-server using REST ?

1 Answers1

2

You can either separate each line with semicolons:

$ curl "http://localhost:8182?gremlin=x=100-1%3Bx-10"
{"requestId":"17bebb7e-3e99-4001-b33a-feca5b39b44f","status":{"message":"","code":200,"attributes":{}},"result":{"data":[89],"meta":{}}}

Note that with the curl statement above, the ; is urlencoded to "%3B" or you can just use newlines in a POST:

$ curl -X POST -d "{\"gremlin\":\"x=100-1\\nx - 10\"}" "http://localhost:8182"
{"requestId":"b5f28f38-e02f-4ab9-9888-3db389ff6f1c","status":{"message":"","code":200,"attributes":{}},"result":{"data":[89],"meta":{}}}
stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Thanks it's works. But I still can't get output for different type like vertex data and math in single query. Well maybe it's gremlin server limitation – Eka Cahya Pratama Jul 01 '16 at 01:47
  • 1
    sure you can. one easy way is to just take every return value and wrap it in a list or a map. so submit something like: `[vertexData: g.V().has('name','hercules').valueMap(true).next(), math: 1+1]`. – stephen mallette Jul 01 '16 at 09:38