question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@QueryMap not working with POJOs as specified in documentation

See original GitHub issue

According 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:closed
  • Created 5 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
kdavisk6commented, May 7, 2018

9.7 was released.

0reactions
3p5i10ncommented, Oct 25, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found