Skip to content

Instantly share code, notes, and snippets.

@dotanh
Created May 17, 2012 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dotanh/2717455 to your computer and use it in GitHub Desktop.
Save dotanh/2717455 to your computer and use it in GitHub Desktop.
RESTful client example using Apache Jersey: POST call
String serverBootResponse =
service.path(this.pathPrefix + "servers")
.header("Content-Type", "application/json")
.header("X-Auth-Token", token)
.accept(MediaType.APPLICATION_XML)
.post(String.class, json);
final DocumentBuilder documentBuilder = createDocumentBuilder();
final Document doc =
documentBuilder.parse(new InputSource(new StringReader(serverBootResponse)));
final String serverId = xpath.evaluate("/server/@id", doc);
return serverId;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment