Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalArgumentException: Parameter type must not include a type variable or wildcard: java.util.List<MyModel> (parameter #5) for method ApiService.myRequest #4195

Open
hackaprende opened this issue Jul 25, 2024 · 1 comment

Comments

@hackaprende
Copy link

I am getting this error when trying to send a list of objects in the body of my post request:

java.lang.IllegalArgumentException: Parameter type must not include a type variable or wildcard: java.util.List (parameter #5) for method ApiService.myRequest

The request is like this:

@POST(MY_URL)
suspend fun makeRequest(@Body myList: List<MyModel>): MyResponse

The error is still present on version com.squareup.retrofit2:retrofit:2.11.0

The solution for now is adding
@JvmSuppressWildcards

This fixes the issue but makes the code less readable and more complex to understand

A solution example for others who have this problem:

@POST(MY_URL)
@JvmSuppressWildcards
suspend fun makeRequest(@Body myList: List<MyModel>): MyResponse
@JakeWharton
Copy link
Collaborator

Are you sure it's on the body parameter? The exception indicates you've trimmed down the example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants