Created
August 16, 2013 14:00
-
-
Save dannyduc/6250195 to your computer and use it in GitHub Desktop.
Sample Jersey Client code to post JSON data
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 characters
String uri = "https://developer.ingenuity.com/datastream/api/v1/activations/a9ab2c34-01b5-4473-864d-0d2f008ae090-5"; | |
String input = "[{\"sampleId\":\"33\",\"activationCode\":\"Lab-act-code-xxx-zzz\"}]"; | |
Client client = Client.create(); | |
ClientResponse response = client.resource(uri) | |
.type(MediaType.APPLICATION_JSON) | |
.header("Authorization", "xxx") | |
.post(ClientResponse.class, input); | |
System.out.println("StatusCode: " + response.getStatus()); | |
ObjectMapper objectMapper = new ObjectMapper(); | |
InputStream stream = response.getEntityInputStream(); | |
Map activationMap = objectMapper.readValue(stream, Map.class); | |
stream.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment