Created
March 31, 2014 20:16
-
-
Save sarmbruster/9901244 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.6') | |
@Grab(group='net.sf.json-lib', module='json-lib', version='2.2.3', classifier='jdk15') | |
import groovyx.net.http.RESTClient | |
import static groovyx.net.http.ContentType.* | |
def http = new RESTClient( 'http://localhost:7474/db/data/transaction/commit', JSON) | |
http.setProxy('localhost', 8888, 'http') | |
def response = http.post(body: [ | |
statements: [ | |
[ | |
statement: 'CREATE (n {props}) RETURN n' , | |
parameters: [ | |
props : [ | |
numericProp: 1, | |
stringProp: '1', | |
// mixedArrayProp: [1, 'abc'] // uncommenting this line gives "Collections containing mixed types can not be stored in properties." | |
anotherStringProp: "[1, 'abc']" // this stores a string property | |
] | |
] | |
] | |
] | |
]) | |
assert response.status == 200 | |
println "Location Header: $response.headers.Location" | |
def data = response.data.results.data[0] | |
println "result columns: ${response.data.results.columns[0]}" | |
println "we have ${data.size()} result rows" | |
data.eachWithIndex { row, index -> | |
println "result ${index}: $row.row" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment