Dynamic change in url in retrofit

I want to call this url http://192.168.122.1/local/date=?user_id=?

I have wrote my api like this

@POST("/local")
void create(@Body User user,
                RestCallback<MyCallback> callback);

The date and userid parameter is dynamic and will change at runtime.How I am gonna call this full url using retrofit.Please help me.

Answer

Just change it like

  @POST("/local")    
  void create(@Query("user_id") String userid,
              @Query("date") String date,
              @Body User user,
              RestCallback<MyCallback> callback);

Hope this helps.

Leave a Reply

Your email address will not be published. Required fields are marked *