Hi,
I'm trying to add a stream.
I'm using "apache httpcomponents" for the communication and "googe json
simple" to handle the JSON Objects.
To add a stream I'm sending a http post with a Json object.
Unfortunately I only get Statuscode 400 in return.
private static void addTestStream(){
String url = "http://78.46.76.183:12900/streams";
HttpClient httpClient = new DefaultHttpClient();
try {
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader(BasicScheme.authenticate(
new UsernamePasswordCredentials(USERNAME, PASSWORD),
"UTF-8", false));
httpPost.addHeader("Accept", "application/json");
httpPost.addHeader("Content-Type", "application/json");
JSONObject jsonObj = new JSONObject();
jsonObj.put("creator_user_id", "chris");
jsonObj.put("title", "testTitel");
jsonObj.put("description", "testing");
StringEntity se = new StringEntity(jsonObj.toJSONString());
se.setContentType("application/json");
se.setContentEncoding("UTF-8");
httpPost.setEntity(se);
HttpResponse httpResponse = httpClient.execute(httpPost);
System.out.println(httpResponse.getStatusLine().getStatusCode());
} catch (Exception e) {
e.printStackTrace();
}
}
The log tells me:
ERROR: org.graylog2.rest.resources.streams.StreamResource - Error while parsing
JSON
com.fasterxml.jackson.databind.JsonMappingException: No content to map due to
end-of-input
at [Source: java.io.StringReader@41b24e0c; line: 1, column: 1]...
Could anyone tell me what I'm doing wrong all the time?
--
You received this message because you are subscribed to the Google Groups
"graylog2" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.