Android @路径作为可选参数?

Android @路径作为可选参数?,android,kotlin,retrofit2,Android,Kotlin,Retrofit2,在我的android项目中,我使用改型: @POST("/correspondents/{correspondent_id}") fun updateCorrespondent(@Path("correspondent_id") correspondentId: String, @Body body: JsonElement): Call<Void> 可能吗 目前,我使用两种不同的方法: @POST("/correspondents/{correspondent_id}")

在我的android项目中,我使用改型:

@POST("/correspondents/{correspondent_id}")
    fun updateCorrespondent(@Path("correspondent_id") correspondentId: String, @Body body: JsonElement): Call<Void>
可能吗

目前,我使用两种不同的方法:

@POST("/correspondents/{correspondent_id}")
    fun updateCorrespondent(@Path("correspondent_id") correspondentId: String, @Body body: JsonElement): Call<Void>

    @POST("/correspondents/create")
    fun createCorrespondent(@Body body: JsonElement): Call<Void>
@POST(“/contracents/{contracenter\u id}”)
fun updateCorrespondent(@Path(“通讯器id”)对应id:String,@Body-Body:JsonElement):调用
@帖子(“/通讯员/创建”)
fun CreateAgenter(@Body:jsoneElement):调用

是否可以只使用一种方法和可选的
@Path

您的API端点是否支持此功能?在您的api端,对应的\u id的默认值是什么point@POST(“/respondents/{respondent_id}”)fun updateCorrespondent(@Path(“respondent_id”)respondent:String?=“create”、@Body Body:jsoneElement):调用将respondent的默认值设置为“create”,现在您可以在不使用respondent的情况下调用此方法,当您需要通过Different id时,请通过newcorrespondentId@KishanMaurya我尝试了以下方法:myRestClient.updateCorrespondent(contractor.toUpdateJson()),但我得到了编译错误:Required String?,找到了JsonElementmtRestClient.updateCorrespondent(body=contractor.toUpdateJson()),我正在发布这个答案。如果决议获得通过,请进行表决
@POST("/correspondents/{correspondent_id}") fun updateCorrespondent(@Path("correspondent_id") correspondentId: String?="create", @Body body: JsonElement): Call<Void>
@POST("/correspondents/{correspondent_id}")
    fun updateCorrespondent(@Path("correspondent_id") correspondentId: String, @Body body: JsonElement): Call<Void>

    @POST("/correspondents/create")
    fun createCorrespondent(@Body body: JsonElement): Call<Void>
@POST("/correspondents/{correspondent_id}") fun updateCorrespondent(@Path("correspondent_id") correspondentId: String?="create", @Body body: JsonElement): Call<Void>
mtRestClient.updateCorrespondent(body = correspondent.toUpdateJson())