Created
June 20, 2016 07:33
-
-
Save dalanlan/1dbb042d5d494a15f87aebdbbc5e219d to your computer and use it in GitHub Desktop.
Revisions
-
dalanlan created this gist
Jun 20, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ package com.hulu.neo4j; /** * Created by simei.he on 6/14/16. */ import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; import sun.misc.BASE64Encoder; public class neoRestClient { public static void main(String[] args) { try { String name = "neo4j"; String pwd = "secret"; String authString = name + ":" + pwd; String authStringEnc = new BASE64Encoder().encode(authString.getBytes()); Client client = Client.create(); WebResource webResource = client.resource("http://localhost:7474/service/neighbor/all/actor/Mariann%20%20Aalda/movie/MV000233260000"); ClientResponse response = webResource.accept("application/json") .header("Authorization", "Basic "+ authStringEnc) .get(ClientResponse.class); if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } System.out.println("Output from Server .... \n"); String output = response.getEntity(String.class); System.out.println(output); } catch (Exception e) { e.printStackTrace(); } } }