try {
//Get a story with defects
System.out.println("\nQuerying for stories with defects...");
QueryRequest storiesWithDefects = new QueryRequest("hierarchicalrequirement");
storiesWithDefects.setQueryFilter(new QueryFilter("Defects.ObjectID", "!=", null));
storiesWithDefects.setFetch(new Fetch("FormattedID", "Name", "Defects:summary[Priority;State]"));
QueryResponse storiesWithDefectsResponse = restApi.query(storiesWithDefects);
JsonObject story = storiesWithDefectsResponse.getResults().get(0).getAsJsonObject();
System.out.println(String.format("Found: %s - %s", story.get("FormattedID").getAsString(), story.get("Name").getAsString()));