Dynamic change in url in retrofit Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Dynamic change in url in retrofit without wasting too much if your time.

The question is published on by Tutorial Guruji team.

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.

We are here to answer your question about Dynamic change in url in retrofit - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji