Post

Replies

Boosts

Views

Activity

Issue with Alamofire network request: "A server with the specified hostname could not be found"
Hello Apple Developer Forum, I'm encountering an issue with Alamofire while making a network request to retrieve data from an API. I'm receiving the following error: "A server with the specified hostname could not be found." I would greatly appreciate any guidance or insights you can provide. Here are some details regarding the issue: // Other import statements and class definitions // Inside a method let apiUrl = "https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=IBM&apikey=QOZH7BJYQ8GRKFKX" AF.request(apiUrl).responseDecodable(of: TimeSeriesData.self) { response in if let data = response.value { // Process the fetched data } else if let error = response.error { // Handle the error } } Troubleshooting steps taken: Verified the API URL by testing it in a web browser, which returns the expected data. Confirmed network connectivity and accessibility of other websites/services. Disabled the firewall and ensured network stability. Tested with other URLs and encountered the same error. Despite these troubleshooting attempts, the issue persists. I'm uncertain whether it's a problem with my network configuration, Alamofire, or any other underlying factors. If anyone has encountered a similar issue or has suggestions on how to resolve it, I would greatly appreciate your insights. Additionally, if you have alternative approaches or suggestions for making network requests in Swift, I'm open to exploring those as well. Thank you in advance for your help! Best regards, Paul A
1
0
604
Jun ’23