Target host is not specified error when using urlEncode()

Hello, I’m using REST services in the app and I need to send a query that includes user input, so I need to encode spaces and special characters. I used replaceAll() for spaces, it works well, but for special characters, I need to use urlEncode(), however when I use it see an error “Target host is not specified” even though the link service includes https://.   What could be the reason of the error and how can I fix it?
1 answers

You can’t encode the full url. You only have to encode the parameters of the url.