Subin Babu
Subin Babu

Reputation: 1555

How to call dynamic Request Method in retrofit android

I have two methods to call an API.

1.POST

2.PUT

Currently, i keep the two versions like

@POST("api_end_point")
  Call<ProfessionalResponse> ProfessionalData(
            @Header("Authorization") String authorization,
            @Body ProfessionalInsertData body);

@PUT("api_end_point")
  Call<ProfessionalResponse> ProfessionalData(
            @Header("Authorization") String authorization,
            @Body ProfessionalInsertData body);

How can I reduce this to a single function or single call in java or kotlin

Upvotes: 1

Views: 659

Answers (1)

Paraskevas Ntsounos
Paraskevas Ntsounos

Reputation: 1777

It is not possible. You can check this issue from github. As comment said it is better to use for this service OkHttp directly which allows you to control all aspects of the HTTP request dynamically.

Upvotes: 1

Related Questions