I want to send enum class to API via Retrofit. For parsing I'm using Gson.
Enum class that I'm sending:
enum class TaskState {
NOT_ASSIGNED,
IN_PROGRESS,
CLOSED,
DELETED }
My Retrofit method:
@PUT("/project/76fd04cc-ae1e-4589-8fe7-11c4f16ce067/task/{taskId}/state/")
suspend fun updateState(
@Path("taskId") taskId: String,
@Body state: TaskState
)
Unfortunately, when I invoke this function, I receive an HTTP 400 error. The headers, project ID, task ID, and TaskState are all 100% correct and in accordance with the API documentation. Other methods described in the documentation work. Below is the link do API's docs. Method that I want to use is described last.
Link to the docs: https://task-manager-api-401408.lm.r.appspot.com/docs/#/default/editTaskState
Where is the problem?
You need to send the
enum
value as astring
. It doesn't know that it is abody enum
.Sample Usage
..
...