retrofit icon indicating copy to clipboard operation
retrofit copied to clipboard

Parameter type must not include a type variable or wildcard: java.util.Map<java.lang.String, ?>

Open DavidCorrado opened this issue 1 year ago • 2 comments

https://github.com/square/retrofit/issues/3275#issuecomment-571335466

Would like a solution that does not involve adding the ignore rule. Can we consider a proper fix.

DavidCorrado avatar Nov 06 '24 18:11 DavidCorrado

This is a limitation of Kotlin, or you can use HashMap<String, Any> instead.

Goooler avatar Jan 24 '25 12:01 Goooler

@DavidCorrado you could use a library like qs-kotlin to pre-serialize your data.

For example, you could take your Map<String, Any> (with ints, strings, etc.) and let qs-kotlin turn it into a URL-encoded query string. It handles mixed-type maps and nested structures gracefully.

You’d then supply that encoded string to the request (e.g., as an @Url for a GET, or as the body for a form POST). This way, you avoid the wildcard type issue  because Retrofit itself no longer sees a generic Map or complex List – you’re only passing a simple string that qs-kotlin produced.

techouse avatar Aug 28 '25 19:08 techouse