Skip to content

Instantly share code, notes, and snippets.

@NetworksAreMadeOfString
Created August 20, 2012 20:42
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 NetworksAreMadeOfString/3407692 to your computer and use it in GitHub Desktop.
Save NetworksAreMadeOfString/3407692 to your computer and use it in GitHub Desktop.
Getting an Event from Zenoss with Android
HttpPost httpost = new HttpPost(ZENOSS_INSTANCE + "/zport/dmd/Events/evconsole_router");
httpost.addHeader("Content-type", "application/json; charset=utf-8");
httpost.setHeader("Accept", "application/json");
JSONObject dataContents = new JSONObject();
dataContents.put("evid",_EventID);
JSONArray data = new JSONArray();
data.put(dataContents);
JSONObject reqData = new JSONObject();
reqData.put("action", "EventsRouter");
reqData.put("method", "detail");
reqData.put("data", data);
reqData.put("type", "rpc");
reqData.put("tid", String.valueOf(this.reqCount++));
httpost.setEntity(new StringEntity(reqData.toString()));
HttpResponse response = httpclient.execute(httpost);
String zenossJSON = EntityUtils.toString(response.getEntity());
response.getEntity().consumeContent();
JSONObject ZenossObject = new JSONObject(zenossJSON );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment