Skip to content

Instantly share code, notes, and snippets.

@smartmic
Created December 30, 2015 21:06
Show Gist options
  • Save smartmic/eaa95cb143c126cb11b6 to your computer and use it in GitHub Desktop.
Save smartmic/eaa95cb143c126cb11b6 to your computer and use it in GitHub Desktop.
HTTP/REST Interface from Julia to Neo4j Database
using Requests, HttpCommon, Codecs
db_key = "neo4j"
db_secret = "neo4j"
# create authentication
function enc_credentials(db_key::String, db_secret::String)
bearer_token_credentials = "$(encodeURI(db_key)):$(encodeURI(db_secret))"
return(base64(bearer_token_credentials))
end
response = post(URI("http://localhost:7474/db/data/transaction/commit"),
"{\"statements\":[{\"statement\":\"CREATE (p:Person {name:{name},born:{born}}) RETURN p\",\"parameters\":{\"name\":\"Keanu Reeves\",\"born\":1964}}]}";
headers = {"Authorization" => "Basic $(enc_credentials(db_key,db_secret))", "Content-Type" => "application/json"},
)
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment