23

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)
Holger
  • 285,553
  • 42
  • 434
  • 765
user3468921
  • 561
  • 2
  • 8
  • 26
  • Please include the code. – ryanyuyu Jan 23 '15 at 16:30
  • 8
    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:3000` – fge Jan 23 '15 at 16:31

6 Answers6

66

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

TuGordoBello
  • 4,350
  • 9
  • 52
  • 78
vahid karimi
  • 1,263
  • 1
  • 12
  • 6
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.

Shubham
  • 707
  • 9
  • 7
1

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

dev.baseURL=http://localhost:8080/products/
Procrastinator
  • 2,526
  • 30
  • 27
  • 36
Developer
  • 11
  • 2
0

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

Ashav Kothari
  • 301
  • 3
  • 7
0

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

  • The accepted answer already highlights this fact. If you would like to add an additional note to an existing answer consider leaving a comment on the answer rather than putting it as a new answer. Post as an answer only If you feel the addition is unique, not covered by other answers and elaborate enough to be posted as a separate answer. – Aditya Patnaik Aug 22 '22 at 07:15
  • @AdityaPatnaik well, the accepted answer doesn't contain the // characters exactly. Still a comment to that answer would have been sufficient – cyberbrain Aug 22 '22 at 19:11
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32511572) – cyberbrain Aug 22 '22 at 19:12
  • @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. – Aditya Patnaik Aug 23 '22 at 04:43
-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)