Wednesday, October 10, 2012

[YouTube-API] YouTube java API - V3

Hi,
I'm trying to use the latest version of the youtube API (V3) but for some reason I'm getting casting exception when calling the list functions (for the different entities)

in the below example I'm getting the following exception when calling the execute method:

Code:

Youtube youTube = new Youtube.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).build();

Map<String, Channel> channels = youTube.channels().list("id").setMine("").execute().getChannels();

Exception:

java.lang.IllegalArgumentException: expected collection or array type but got java.util.Map<java.lang.String, com.google.api.services.youtube.model.Channel> [key channels, field private java.util.Map com.google.api.services.youtube.model.ChannelListResponse.channels]

at com.google.common.base.Preconditions.checkArgument(Preconditions.java:115) ~[guava-11.0.1.jar:na]

at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:534) ~[google-http-client-1.11.0-beta.jar:1.11.0-beta]

at com.google.api.client.json.JsonParser.parse(JsonParser.java:352) ~[google-http-client-1.11.0-beta.jar:1.11.0-beta]

at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:588) ~[google-http-client-1.11.0-beta.jar:1.11.0-beta]

at com.google.api.client.json.JsonParser.parse(JsonParser.java:291) ~[google-http-client-1.11.0-beta.jar:1.11.0-beta]

at com.google.api.client.json.JsonParser.parse(JsonParser.java:268) ~[google-http-client-1.11.0-beta.jar:1.11.0-beta]

at com.google.api.client.json.JsonParser.parseAndClose(JsonParser.java:143) ~[google-http-client-1.11.0-beta.jar:1.11.0-beta]

at com.google.api.client.http.json.JsonHttpParser.parse(JsonHttpParser.java:90) ~[google-http-client-1.11.0-beta.jar:1.11.0-beta]

at com.google.api.client.http.HttpResponse.parseAs(HttpResponse.java:501) ~[google-http-client-1.11.0-beta.jar:1.11.0-beta]

at com.google.api.services.youtube.Youtube$Channels$List.execute(Youtube.java:271) ~[google-api-services-youtube-v3alpha-rev13-1.8.0-beta.jar:na]


Any idea? I'm using the latest java client.

Thanks,

Efi

--
Starting October 15, 2012, this group will stop accepting new posts. We recommend that developers start using Stack Overflow and the Issue Tracker for YouTube API support. More details about this change and relevant links can be found at http://apiblog.youtube.com/2012/09/the-youtube-api-on-stack-overflow.html
 
 

No comments:

Post a Comment