Pages

Saturday, March 15, 2014

How to get User Subscription details from Rally




//Below code gives the User Details Subscriptions
private JsonObject getSubScriptionResponse() {

                RallyRestApi restApi = new RallyRestApi(new URI(rallyURL),
"user@yourcomapany.com", "password");
QueryRequest subscriptionRequest = new QueryRequest("Subscriptions");
subscriptionRequest.setFetch(new Fetch("Name", "SubscriptionID",
"Workspaces", "Name"));

QueryResponse subscriptionQueryResponse = null;
JsonObject subscriptionQueryObject = null;
try {
subscriptionQueryResponse = restApi.query(subscriptionRequest);
JsonArray subscriptionQueryResults = subscriptionQueryResponse
.getResults();
JsonElement subscriptionQueryElement = subscriptionQueryResults
.get(0);
subscriptionQueryObject = subscriptionQueryElement
.getAsJsonObject();
this.subscriptionId = subscriptionQueryObject.get("SubscriptionID")
.toString();
System.out.println("Read Subscription: " + subscriptionId);
} catch (IOException e) {
e.printStackTrace();
}
return subscriptionQueryObject;

}

No comments:

Post a Comment