Pass more than one parameter through the URL

Asked

Viewed 2,105 times

0

I have the following code:

public interface service {

        @GET("?acao=R&tipo_refeicao={tipo}&data={data}")
        public void getCardapio(
           Callback<List<Cardapio>> getCardapio(@Query("tipo") int tipo, @Query("data") String data);
        )

}

How do I pass more than one parameter?

I want to pass int and string which is a date. It would be correct like this?

How would it be right?

1 answer

1


As I explained in this question how to create a model to receive the values properly, as you need to pass some parameters, you can use the @Query. See below

@GET("/restaurante")
Call<Cardapio.Conteudo> getCardapio(@Query("tipo") int tipo, @Query("data") String data);

See below for an example of the result of the above call:

/restaurante?tipo=SALADAS&data=2017-08-01

I also answered another question exemplifying the use of @Path, in which would be another alternative to solve your problem. For more details and examples, see more about the type notation Query in the documentation.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.