Learn Courses My Dashboard

Youtube API/Playlist Tutorial: Cannot make GET request

Hi guys! So I have been following this tutorial: How To Make a YouTube Video App - YouTube
I am using the internet trafficking tool to see if I get that initial GET request to the youtube API. My problem is, I get the error at the breakpoint after the call: let dataTask = session.dataTask(with: url!) { (data, response, error) in. In other words, the breakpoint reaches: if error != nil || data == nil {return }.
I’m not sure why that is, I know for a fact that all of my constants are correct (API key, url, playlist ID) because I have tested the url within the browser and I get the returned playlist json data in the browser. I don’t even see the GET request Chris is getting in the trafficking tool. I do see a youtubeapi connect 200 status, but that is all. Any reason why it’s not making the GET request? Is the tutorial outdated to the latest version of Xcode?

Also, I do realize I have this displayed initially in the console: nw_protocol_get_quic_image_block_invoke dlopen libquic failed I’m not sure what this exactly means, or if it is related to the problem at hand.

Hi @matson

Welcome to the Code Crew community.

I followed that YouTube One day build course a while ago.

I’m assuming that your API_KEY is OK and your PLAYLIST_ID is also OK.
My API_URL might be structured slightly different to yours (I played around with the settings after I finished the course):


Inside your dataTask, if you set the breakpoint at the line that says:

let decoder = JSONDecoder()

and run the code does it stop there or does it not even get there?

So I placed the breakpoint at that exact line. It should be in Model.swift right? Yes, when I debug it does reach the breakpoint. However, it does not reach if response.items != nil { //if there are videos… where I also placed it. I do not see the GET request yet also in my traffic.

I also get nothing in the console.

I didn’t bother using that traffic tool that Chris was talking about.

All I made sure of was that the decoder worked.

If it didn’t then there was a likelihood that the problem was either in the Response struct or in the Video struct and to do with the CodingKeys or the code inside the init() method inside the Video struct.

Have you got this working now @matson ?