I have already asked a lot of questions about developing an application using the retrofit library, and after all the answers I realized that I needed to initially structure the task and understand what to do, and then ask questions. So I need to get a list of incoming messages from the server and then work with them. In my previous questions: How to send a get retrofit android request? You can see the information that was provided by the developers of the server side of the application. And I had a question whether you need to create a bunch of get requests to get all the parameters of the message, or whether you need to create one request to fit all the parameters. The second question is whether it is necessary to create a class query and a class response for the implementation of this task, or you can get by with the query class only. I already have a post request that I implemented using only the interface and the request class, for some reason it seemed to me that these two types of requests are the same, but it turned out that it is not. Thanks in advance for any help and helpful advice.

    1 answer 1

    A bunch of get-requests for one message, and they are also a list - do you think it’s very nonsense? In one request, you get everything (or rather, a portion of messages, judging by the info backend).

    If you do not need to transfer data to the server in the request body, then the class describing this body is, of course, not needed.
    But the response class is required.
    Create a class to answer:

    • when you want to get data from a response in the form of a java-object, you need to describe its class and specify this class in the api-interface.
    • not needed when you need a "raw" response (string, byte array) - specify the standard class ResponseBody
    • no need when the answer can and should be converted into some other existing class (list of strings, for example - List<String> ) - and specify it in the interface
    • that is, you need to create one query with the @Query parameter, but further about converting to another class from the last item in your list is not very clear, I need to register there all the fields that will be on this list? - Andrew Goroshko
    • This is if the response format is suitable for converting to this class. For List<String> , for example - it can be json of the form: ["текст","ещё_текст","снова_текст", "всё_время_текст"] - woesss
    • Well, yes, I get from the server json a further I need to scatter it on the list. From your answer, I can conclude that I do not need a request class, but I need a response class, where all the fields that I receive from the server in json will be written. - Andrew Goroshko
    • That's right - more precisely, you need two classes to answer, as you have already been offered: ru.stackoverflow.com/a/859246/11515 . Only the api-interface method needs to be brought to mind, according to the backend dock (add authorization header, fix the path and query. - woesss
    • Thanks I will pick further, if that I ask questions more accurately. - Andrew Goroshko