iOS: Get a 404 Error on YouTube Analytics API

125 views
Skip to first unread message

Brand Watch

unread,
Oct 18, 2014, 8:46:00 PM10/18/14
to google-apis-e...@googlegroups.com
Hi,

We are trying to retrieve Youtube analytics data for our own channel. We're using GTLQueryYouTubeAnalytics.
This is an iPhone App written in Swift using Xcode 6

This is what we have:


        var scope = "https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/yt-analytics-monetary.readonly https://www.googleapis.com/auth/yt-analytics.readonly https://www.googleapis.com/auth/youtubepartner https://www.googleapis.com/auth/youtube.readonly"


        

        var vc = GTMOAuth2ViewControllerTouch(scope: scope, clientID: clientID, clientSecret: clientSecret, keychainItemName: kKeyChainItemName, delegate: self, finishedSelector:Selector("authentication:finishedWithAuth:error:"))


In authentication(){


        ....

        ....

        // On Success

        service = GTLServiceYouTube()

        service.authorizer = finishedWithAuth


        // Channel is my Channel ID

        var newQuery: GTLQueryYouTubeAnalytics = GTLQueryYouTubeAnalytics.queryForReportsQueryWithIds("channel==*****", startDate: "2014-10-15", endDate: "2014-10-16", metrics: "views,likes,shares,comments") as GTLQueryYouTubeAnalytics

        

        var ticket1 = GTLServiceTicket()

        ticket1 = service.executeQuery(newQuery, completionHandler: { (ticket: GTLServiceTicket!, object: AnyObject!, error: NSError!) -> Void in

            

            println("Analytics: \(object) or \(error)")

            

        })


}


This is my output:


Analytics: nil or Error Domain=com.google.GTLJSONRPCErrorDomain Code=404 "The operation couldn’t be completed. (Not Found)" UserInfo=0x***** {error=Not Found, NSLocalizedFailureReason=(Not Found), GTLStructuredError=GTLErrorObject 0x7f8e43ddc9b0: {message:"Not Found" data:[1] code:404}}



--------------------------------------------------------------------


What are we missing here? We ran a previous query for the YouTubeDataAPI and that worked well.


Any thoughts appreciated!


Thanks,

BW Team

Brand Watch

unread,
Oct 19, 2014, 2:44:08 AM10/19/14
to google-apis-e...@googlegroups.com

The root cause of the issue was the Service used. The correct service to be used is:

service = GTLServiceYouTubeAnalytics()

Reply all
Reply to author
Forward
0 new messages