Hi, I'm trying to get the feed by calling the API below.
public static void main(String[] args) throws Exception
{
try
{
String urlString = "https://api.nationaltransport.ie/gtfsr/v2/gtfsr?format=json";
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
//Request headers
connection.setRequestProperty("Cache-Control", "no-cache");
connection.setRequestProperty("x-api-key", YOUR_API_KEY);
connection.setRequestMethod("GET");
int status = connection.getResponseCode();
System.out.println(status);
FeedMessage feed = FeedMessage.parseFrom(connection.getInputStream());
for (FeedEntity entity : feed.getEntityList()) {
if (entity.hasTripUpdate()) {
System.out.println(entity.getTripUpdate());
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
This error is thrown: com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag.
If I tried to read this into a plain text, it works fine. Am I doing something wrong here? I suspect it might be that I'm requesting the wrong format? Sorry, I'm new to all these.
Hi, I'm trying to get the feed by calling the API below.
This error is thrown:
com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag.
If I tried to read this into a plain text, it works fine. Am I doing something wrong here? I suspect it might be that I'm requesting the wrong format? Sorry, I'm new to all these.