first, I have to say, that there are many links here that user asked same question, but none of them helps, so please don't remove my question.
I want to videos from youtube API, there are some parameters that I should send with, first I add them into header but apparently it doesn't help.
Here is my url
let url = Url(String: "https://www.googleapis.com/youtube/v3/playlistItems")
and here are the parameters (I added to header but it's wrong)
var request = URLRequest(url: url!)
request.httpMethod = "GET"
request.allHTTPHeaderFields = [
"part" : "snippet",
"key" : api_key,
"playlistId": trailerPlayListId
]
In some post, I read that I can change URL
to URLComponents
and add queryItems
, but when I do that, I can't add it to URLRequest
, it need URL
var request = URLRequest(url: url!)
Could anyone help me on that? Thanks