Reputation: 4360
I have just downloaded the Google API objective C client. I opened the YouTube example project in Xcode on my Mac. It builds and runs without errors.
I registered a project with Google APIs, and created a Client ID for installed applications, choosing iOS and entering the sample code's Bundle ID, com.example.YouTubeSample. I left the App Store ID blank and deep linking disabled.
I entered the resulting Client ID and Client secrets into the sample app. I signed myself into Google through the app's window too, and it tells me I am signed in.
Independently I went to YouTube and uploaded a 1Mb .mov file, which uploads fine (although it tells me there may be an audio/video sync issue).
I then uploaded the same file through the sample app. When it finished, it gave me the error:
Error Domain=com.google.GTLJSONRPCErrorDomain Code=-32602
"The operation couldn’t be completed. (Bad Request)"
UserInfo=0x.... {error=Bad Request, NSLocalizedFailureReason=(Bad Request),
GTLStructuredError=GTLErrorObject 0x...:
{message:"Bad Request" data:[1] code:-32602}}
(Since the sample app is for Mac OS, not iOS, I also tried creating a second Client ID in Google APIs, for an installed application of type "other". I entered this new ID and secret into the sample app, and when I uploaded the .mov file I got the same error.)
Over in the API console, I see an error report showing some new Error code 400s.
What have I done wrong?
thanks!
Upvotes: 3
Views: 1072
Reputation: 4821
The YouTube API packs a "structured error" object inside of the NSError
object that it returns. The structured error is a GTLErrorObject
that can be inspected to find the reason for the error:
uploadTicket = [service executeQuery:query
completionHandler:^(GTLServiceTicket* ticket, id object, NSError* error) {
if (error) {
GTLErrorObject* const errorObject = error.userInfo[kGTLStructuredErrorKey];
NSLog(@"error from YouTube API: %@", errorObject.data);
}
...
}];
Sample output (formatted for clarity):
error from YouTube API: (
GTLErrorObjectData 0x7fb0c4cc9f10: {
message:"Bad Request"
locationType?:"other"
reason:"invalidCategoryId"
domain:"youtube.video"
location:"body.snippet.categoryId"}
)
Upvotes: 1
Reputation: 4360
I just quit and restarted Xcode and the sample project, and it worked (using the iOS client ID, I haven't tried the other one).
Happy days!
Upvotes: 0