Search code examples
androidrequestretrofit2

How to realize Path Variable in retrofit 2


I can't send DELETE request with path variable. It's working in Postman. Please help me.

UPD:

API Interface: @HTTP(method = "DELETE", path = "users/id:{id}", hasBody = true) fun deleteUser(@Path("id") id: String): Call<ResponseBody>


Solution

  • If you are using retrofit 2. Try like this

    @DELETE("delete_labour/{id}")
    Call<JsonElement> delete_item(@Path("id")String id,
                                    @Header("token")String token);