Created
August 20, 2012 20:42
-
-
Save NetworksAreMadeOfString/3407692 to your computer and use it in GitHub Desktop.
Getting an Event from Zenoss with Android
This file contains 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
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