2

I am facing the following exception when i try to call method on server, can any one tell me what is the problem ?

stacktrace

java.io.FileNotFoundException: https://services.q84sale.com/live/index.php/V1/Users/register
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:186)
com.android.okhttp.internal.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:246)
com.forsale.forsale.controller.manager.ForSaleNetworkManager.execute(ForSaleNetworkManager.java:116)
com.forsale.forsale.controller.manager.ForSaleServerManager$18.doInBackground(ForSaleServerManager.java:1423)
com.forsale.forsale.controller.manager.ForSaleServerManager$18.doInBackground(ForSaleServerManager.java:1399)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:848)
1
  • You are tring to access a web server file as if it was a file located on your file system. Which is wrong by definition. This is what you are presented with, if you try opening that path in FireFox: {"status":400,"error":{"code":1,"message_en":"Invalid HTTP Method. Only POST is Accepted.","message_ar":"Invalid HTTP Method. Only POST is Accepted."}}. It seems you need a tutorial on webservices. Commented Feb 21, 2016 at 12:00

1 Answer 1

1

Too little information for right answer. Probably:

  1. You specified an object with in your query that doesn't exist on server
  2. You are using wrong method (GET, PUT) instead of POST
  3. Server has some errors in its code

Add:

I noticed you are using .getInputStream() after receiving response code above 399. Check .getResponseCode() and then use .getErrorStream() instead

Sign up to request clarification or add additional context in comments.

2 Comments

Server return error code 422 with JSON object contains error message when I test the request on postman.
Returning a java.io.FileNotFoundException is just a very bad design decision. There are man 4xx HTTP codes which have nothing to do with files. In our case it was HTTP 420.

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.