@QueryMap not working with POJOs as specified in documentation
See original GitHub issueAccording to: https://github.com/OpenFeign/feign#dynamic-query-parameters it should be possible to write:
@RequestLine("GET /api/v1/historicalTrades") fun getHistoricalTrades(@QueryMap orderBookQuery: OrderBookQuery): List<TradeEntry>
where OrderBookQuery looks like that:
data class OrderBookQuery(val symbol: String, val limit: Int? = 100)
Feign should generate: /api/v1/historicalTrades?symbol={symobl}&limit={limit}
but I’m getting:
Exception in thread "main" java.lang.IllegalStateException: QueryMap parameter must be a Map: class com.binance.api.feign.marketdata.model.OrderBookQuery
at feign.Util.checkState(Util.java:128)
at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:126)
at feign.Contract$BaseContract.parseAndValidatateMetadata(Contract.java:64)
at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:146)
at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:53)
at feign.Feign$Builder.target(Feign.java:198)
at feign.Feign$Builder.target(Feign.java:194)
Here is my config and usage that produces above exception:
val marketDataRestClient =
Feign.builder().encoder(GsonEncoder())
.decoder(GsonDecoder())
.logger(Logger.ErrorLogger())
.logLevel(Logger.Level.FULL)
.target(MarketDataRestClient::class.java, "https://api.binance.com")
val s = marketDataRestClient.getHistoricalTrades(OrderBookQuery("ETHBTC"))
Link to my SO if someone wants to get them free karma points 😉 : https://stackoverflow.com/questions/50044283/feign-querymap-usage-with-pojo
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
QueryMap pass parameters in the body - Stack Overflow
Found out that using spring-cloud-openfeign I should use @SpringQueryMap instead of @QueryMap as stated in the docs.
Read more >PojoQueryBuilder (MarkLogic Java Client API 5.0.0)
It adds convenience methods specific to working with pojos and does not replicate ... Filter search results by properties matching specified value.
Read more >Spring Cloud OpenFeign
Unfortunately, the default OpenFeign QueryMap annotation is incompatible with Spring because it lacks a value property.
Read more >Retrofit 2 — Add Multiple Query Parameter With QueryMap
Future Studio is helping 5,000+ users daily to solve Android and Node.js problems with 460+ written tutorials and videos. We're on a mission...
Read more >Typesafe HTTP Clients with OkHttp and Retrofit - Reflectoring
In the further sections, we will work on creating a Retrofit client and look ... If we do not specify the timeouts, default...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
9.7 was released.
While trying to reproduce it again in a separate sample project, i was not able to. Now 9.7 and 10.0.1 are working fine …have to check my base project again.
Sorry for the inconvenience and the late response, been busy the last weeks.