java.lang.IllegalArgumentException: Illegal character in scheme at index 0: localhost
Asked Answered
G

6

25

I'am developping an android app that receive an data from server (localhost - mssql and nodejs), save data and then display it

after receiving the server response I get this error

I follow the instructions below enter link description here instead of the web server I use localhost. Thank you

 Illegal character in scheme at index 0: 192.168.2.7:3000
    java.net.URISyntaxException: Illegal character in scheme at index 0: 192.168.2.7:3000
            at java.net.URI.validateScheme(URI.java:419)
            at java.net.URI.parseURI(URI.java:363)
            at java.net.URI.<init>(URI.java:204)
            at cz.uhk.fim.jedlima3.searchrooms.asyncTask.DownloadDatabaseAsync.doInBackground(DownloadDatabaseAsync.java:30)
            at cz.uhk.fim.jedlima3.searchrooms.asyncTask.DownloadDatabaseAsync.doInBackground(DownloadDatabaseAsync.java:15)
            at android.os.AsyncTask$2.call(AsyncTask.java:287)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
            at java.util.concurrent.FutureTask.run(FutureTask.java:137)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
            at java.lang.Thread.run(Thread.java:864)
Germinative answered 23/1, 2015 at 16:29 Comment(2)
Please include the code.Conducive
THis is indeed not a valid URI; somewhere in your config files or wherever you put 192.168.2.7:3000 and that's not a valid URI; you probably meant http://192.168.2.7:3000Nirvana
T
71

you should remove space from url and define scheme http or https

Taler answered 19/10, 2015 at 10:13 Comment(1)
Thank you so mcuh. Your answer working to meSierrasiesser
S
4

Do not put " while defining the URL in the properties file like this:

dev.baseURL=http://localhost:8080/products/
Sociolinguistics answered 19/7, 2022 at 15:8 Comment(0)
D
2

If you are Using localhost then pass url like this- http://localhost:8080/api/notes defining scheme is important (http/https) do not use space also.

Desjardins answered 5/9, 2019 at 12:31 Comment(0)
B
1

Make sure you do not forget the // in http://

Belt answered 18/8, 2022 at 1:36 Comment(3)
@AdityaPatnaik well, the accepted answer doesn't contain the // characters exactly. Still a comment to that answer would have been sufficientTownsend
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewTownsend
@cyberbrain, thanks for your review. I feel the reason why the accepted answer doesn't have it or implicitly has it is because it was already covered in a comment on the question back in 2015. Also, using a // after http is a basic understanding and doesn't require an explicit mention in the answer. I assume that the user whose answer is accepted thought this fundament to be understood by the readers.Jellicoe
P
0

Make sure you don't have spell mistake in URL,http:// or https://

Planet answered 9/2, 2021 at 12:51 Comment(0)
C
-1

While we are using any services which are running on our local machines, please try to call the service by using the http protocal instead of directly calling the service. Example: localhost:1234/hello(wrong will give the above exception) http://localhost:1234/hello(correct way)

Cierracig answered 20/6, 2020 at 6:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.