The issue there is that "?" is not part of the path. It should be automatically added when you add the query items components of your URL:

let host = "www.google.com"
let path = "/service/getData"
let queryItems: [URLQueryItem] = [.init(name: "cc", value: "al"),
                                  .init(name: "lastDate", value: "")]
var urlComponents = URLComponents()
urlComponents.scheme = "https"
urlComponents.host = host
urlComponents.path = path
urlComponents.queryItems =  queryItems
urlComponents.url?.absoluteString  // "https://www.google.com/service/getData?cc=al&lastDate="

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top