Unable to convert string to URL in Swift iOS

In order to make HTTP request call using URLSession, I need to convert string to URL first
I have tried everything but just can’t convert this piece of string to URL(string: ).
This is the string:

I can’t share the exact Url but format is all same.
The actual url with same format works fine in browser but no way in Swift, also that works fine in POSTMAN
I have also tried URLComponents which hepls me create the URL from components to URL but that fails with 400 status code response error.
I really appreciate the help, I am completely bogged down with this isuue and can’t proceed with my assignment.

Understanding that you can’t share the URL, you will need to diagnose potential DNS issues on your own. There are many tools to do this and it goes beyond the topic of this forum. The reason it may work on your browser or Postman could be cache, etc.

Have you used a different URL in your code? Maybe something known such as apple.com?

Lastly, it would help for you to show the snippet of code you are using to do the URL and the exact exception being thrown. The more details you provide, the better someone may help.

This topic was automatically closed after 166 days. New replies are no longer allowed.