I am trying to execute the example found on the socrata-soda Api which is
import com.socrata.api.HttpLowLevel;
import com.socrata.api.Soda2Consumer;
import com.socrata.model.soql.SoqlQuery;
import com.sun.jersey.api.client.ClientResponse;
.....
Soda2Consumer consumer = Soda2Consumer.newConsumer("https://sandbox.demo.socrata.com",
"[email protected]",
"OpenData",
"D8Atrg62F2j017ZTdkMpuZ9vY");
ClientResponse response = consumer.getHttpLowLevel().query("nominationsCopy",
HttpLowLevel.JSON_TYPE,
SoqlQuery.SELECT_ALL);
This however is giving me this error
The method query(String, MediaType, SoqlQuery) is undefined for the type HttpLowLevel
I had a look at the java doc, but couldn’t find anything to help me. There isnt even a query
method on HttpLowLevel class
You should use the query
method on the Soda2Consumer
class instead. You also don't need to authenticate unless you're accessing a private dataset or updating a dataset. Here's what the example should reflect:
Soda2Consumer consumer = Soda2Consumer.newConsumer("https://sandbox.demo.socrata.com");
ClientResponse response = consumer.query("nominationsCopy",
HttpLowLevel.JSON_TYPE,
SoqlQuery.SELECT_ALL);
String payload = response.getEntity(String.class);
System.out.println(payload);
I'll update the example in GitHub too.