The www.odata.org website demonstrates how to consume OData services 'in 6 steps'. I'm stuck on Step 3 of the examples located directly on the homepage. I am purposely using only the standard Java 7 libraries. The below code produces a 400 response. I have verified that the URL is correct by attempting the same query using the Advanced Rest Client in Chrome.
Can anyone please show me how to successfully complete step 3 using only the standard Java 7 libraries?
URL url = new URL("http://services.odata.org/V4/TripPinServiceRW/People?$top=2&$filter=Trips/any(d:d/Budget gt 3000)");
HttpURLConnection c = (HttpURLConnection) url.openConnection();
c.setRequestProperty("accept", "application/json");
c.setRequestProperty("Content-Type", "application/json");
c.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(c.getInputStream()));
String input;
StringBuilder sb = new StringBuilder();
while ((input = in.readLine()) != null) {
sb.append(input);
}
in.close();
System.out.println(sb);