Search code examples
androidkotlinserializationmvvmretrofit2

GET request with Query as object


I need to make @GET request with parameters likes this:

@GET("some_url")
suspend fun getSomething(
@Query("simpleString") someString: String,
@Query("objectThatINeedToPass") someObject: SomeDataObjectForGetRequest
): List<BackendObject>

If i'll use @Body instead of @Query than Android Studio throws exception like this: "..... @Body used with non-body request"

Please help me!


Solution

  • GET requests don't have a request body, you should use POST if you send a body