1

I have a url with stringified JSON object appended as below -

http://localhost:53692/api/ccdata/UserWatchlist?userid=2&watchlist={\"Coin\":[\"BTC\",\"ETH\",\"LTC\",\"DASH\"]}

Now my problem is URLRequest(url: URL(string: url)!) can't process this url and giving me nil error

What should I do?

5
  • 2
    you have to encode url with percentage then it will be valid Commented Aug 2, 2018 at 7:49
  • 1
    See this stackoverflow.com/a/49492592/4601900 Commented Aug 2, 2018 at 7:53
  • 3
    Possible duplicate of ios URL(string: ) not working always Commented Aug 2, 2018 at 7:56
  • are you using Alamofire or URL Session ? in alamofire you can do this let Request: String = String.init(format:"http://localhost:53692/api/ccdata/UserWatchlist?userid=2&watchlist={\"Coin\":[\"BTC\",\"ETH\",\"LTC\",\"DASH\"]}") Commented Aug 2, 2018 at 8:02
  • @PrashantTukadiya your solution worked for me.Thanks. Commented Aug 2, 2018 at 8:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.