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.

@RequestMapping "path" is not considered in Feign contract even though it's an alias for "value"

See original GitHub issue

The following client definition ends up ignoring the “path” argumet in RequestMapping, therefore causing a “java.lang.IllegalStateException: Body parameters cannot be used with form parameters.”.

To correct this all you have to do is to change “path” to “value”, but since those are aliases the implementation should example both.

    @FeignClient(url = "http://localhost:8181")
    interface PlatformClient {
        @RequestMapping(path = "/rest/some/{id}",
                method = RequestMethod.POST,
                produces = MediaType.APPLICATION_JSON_VALUE)
        void execute(@PathVariable(value = "id") String id, SomeObject data);
    }

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
zdRancommented, Apr 16, 2018

Request body parameters should be placed in front. try void execute( SomeObject data,@PathVariable(value = "id") String id);

0reactions
jzoecommented, May 15, 2018

It works! @zdRan

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - @RequestMapping "path" is not considered in Feign ...
RequestMapping "path" is not considered in Feign contract even though it's an alias for "value"
Read more >
Can't get Feign Client to work for a basic example
I was able to use Feign successfully although we did not really use 'ribbon'. We used as Rest Client since it is much...
Read more >
7. Declarative REST Client: Feign - Spring Cloud
To specify your own alias value you can use the qualifier value of the @FeignClient annotation. The Ribbon client above will want to...
Read more >
Using the Spring @RequestMapping Annotation
The class-level annotation maps a specific request path or pattern ... a default value when the request param is not provided or is...
Read more >
Spring Annotations: @RequestMapping and its Variants
Here, after the mapping, we encase the path variable with curly brackets ( {} ) and assign that value to our productId ....
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