I use wheaterapi.com and create url with init URL(string: urlString). If I use the received url in a browser, I can get valid answer, and get all data, but if I use url with my app I get error. How fix it?
func ferchFromServer(cityName: String) {
    let urlString = "https://api.weatherapi.com/v1/current.json?key=\(apikey!)&q=\(cityName)"
    let url = URL(string: urlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!)
    print(url!)
    let session = URLSession(configuration: .default)
    let task = session.dataTask(with: url!) { (data, response, error) in
        if let receivedData = data {
            if let datas = self.parseJSON(data: receivedData){
                self.delegate?.updateInterface(self, datas: datas)
            }
        }
    }
    task.resume()
}
print(url) > https://api.weatherapi.com/v1/current.json?key=<MYKEY>&q=New%20York 
its valid url and if entered it in a text field of browser, its work (instead MYKEY - my valid key)
but app return > The data couldn’t be read because it isn’t in the correct format.
P.S. if I try use city from 1 word (for example Moscow of Stambul) code working and don't return this error
 
    