I’m calling an API but here some values are empty and optional so I want to remove them from the URL.
@GET("entriesAcceptance/v${Constants.API_VERSION}/param1/{param1Value}/param2/{param2Value}/entries?")
suspend fun getEntries(
@Path("param1") param1Value: String,
@Path("param2") param2Value: String,
@Query("firstName") firstName: String
@Query("lastName") lastName: String
): EntriesResponse
Here lastName
is empty and but still it’s getting passed in the url. I just want it not to be passed if it doesn’t have any value. Currently URL gets printed as
entriesAcceptance/v1/param1/XXX/param2/XX/entries?&firstName=VULCANO&lastName=
It would be great help if you can help me resolve it. I tried to use @QueryMap
but it does not work with String
.