Android Retrofit returns status of 500 internal server errors

I use Retrofit to get all books and delete all books.

 @GET("/books")
    BookListResponse getAllBooks();
    @DELETE("/clean")
    Response deleteAllBooks();

But error status 500 was returned (internal server error). I tested these two quiet calls with the Chrome restful client application and they work properly.

However, if I just want to get one book or delete one book like this

 @GET("books/1")
    BookResponse getOneBook();
    @DELETE("books/1")
    Response deleteOneBook();

They may work correctly.

So, I'm not sure if there is a problem with the server, or am I missing something?

Thank you very much.

+4
source share
3 answers

: ", ", , , , ( , DELETE /). 500. ", 1", , ( , DELETE /books/ 1).

, , , - REST . , , , , , .

, 500, . Android, .

+3

:

Request request = new Request.Builder()
                .url(urlString)
                .header("accept", "application/json")
                .build();
+2

Update
In "Appendix 2.1" the query builder has been changed, so you need to specify a header in the methods of the modified interface

@Headers("Accept: application/json") @GET("products") Call<Products> getAllProducts();

+1
source

Source: https://habr.com/ru/post/1535078/


All Articles