Pushpendrapatel / google-api-objectivec-client

Automatically exported from code.google.com/p/google-api-objectivec-client
0 stars 0 forks source link

The type of GTLYouTubeSearchResult property "identifier" is wrong #63

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Run the following code.
  GTLServiceYouTube *service = [GTLServiceYouTube new];
  service.APIKey = @"API Key";
  GTLQueryYouTube *query = [GTLQueryYouTube queryForSearchListWithPart:@"snippet"];
  query.q = @"test";
  [service executeQuery:query
      completionHandler:^(GTLServiceTicket *ticket, GTLYouTubeSearchListResponse *response, NSError *error) {
    [response.items enumerateObjectsUsingBlock:^(GTLYouTubeSearchResult *item, NSUInteger idx, BOOL *stop) {
      GTLYouTubeResourceId *identifier = item.identifier;
      NSLog(@"Video ID: %@", identifier.videoId);
    }];
  }];

What is the expected output? What do you see instead?
Expected output:
All video IDs of search results;

Saw instead:
-[GTLYouTubeVideo videoId]: unrecognized selector sent to instance 
0x60000024ddd0

What version of the product are you using? On what operating system?
r393(installed by CocoaPods as Google-API-Client 0.1.1) for OS X 10.9.3

Please provide any additional information below.
"identifier" is defined as follows in GTLYouTubeSearchResult.h
  @property (retain) GTLYouTubeResourceId *identifier;

Original issue reported on code.google.com by mshiban...@gmail.com on 17 May 2014 at 2:27

GoogleCodeExporter commented 9 years ago
Turn on the library's http logging feature and inspect the types of objects 
returned in the server's response.

Look at the objects in the response in the debugger.

Original comment by grobb...@google.com on 24 May 2014 at 2:01

GoogleCodeExporter commented 9 years ago

Original comment by manageiv...@gmail.com on 24 May 2014 at 7:57

Attachments:

GoogleCodeExporter commented 9 years ago
This is a mistake in the YouTube API (internal Google bug number b/10691692). 

The API server is returning a resource identifier like this:

  "id" : {
          "kind" : "youtube#video",
          "videoId" : "VxcbppCX6Rk"
        }
Normally that would be instantiated into a GTLYouTubeResourceId object, but the 
"kind" field tells the client library to instantiate the class with the kind 
string "youtube#video", which is GTLYouTubeVideo, so the library properly 
creates that object.

As a workaround, you can use the library's surrogates feature to change which 
class gets instantiated for the specific query's ticket:

ticket.surrogates = @{ (id)[GTLYouTubeVideo class] : [GTLYouTubeResourceId 
class] };

To be notified when and if this is fixed, you can file a separate issue against 
the YouTube API to ask the API server developers to fix the "kind" string for 
that response. YouTube API issues are filed with the form at

https://code.google.com/p/gdata-issues/issues/entry?template=YouTube%20(Defect%2
0Report)

Please reference the bug number above if you do file an issue.

Original comment by grobb...@google.com on 30 May 2014 at 2:51

GoogleCodeExporter commented 9 years ago
To clarify my previous comment a bit, the API kind string in the server 
response is incorrectly telling the library to instantiate the GTLYouTubeVideo 
class when the library would otherwise create a GTLYouTubeResourceId object. 

That field in the server response should have been named something other than 
"kind" to avoid misleading the library.

Original comment by grobb...@google.com on 30 May 2014 at 3:03