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

Body argument missing for consumes=MediaType.ALL endpoints #2334

Closed
fabienrenaud opened this issue Nov 13, 2019 · 2 comments
Closed

Body argument missing for consumes=MediaType.ALL endpoints #2334

fabienrenaud opened this issue Nov 13, 2019 · 2 comments
Milestone

Comments

@fabienrenaud
Copy link
Contributor

fabienrenaud commented Nov 13, 2019

Steps to Reproduce

  1. Write a simple controller:
public class App {

  @Controller
  public static class Control {

    @Post(value = "/example/bug", consumes = MediaType.ALL)
    public Object ep(@Body Object body) {
      return body;
    }
  }

  public static void main(String[] args) {
    Micronaut.run(App.class, args);
  }
}
  1. Run and curl:
curl localhost:8080/example/bug --data 'foobar'

Returns:

{"message":"Required Body [Object body] not specified","path":"/body","_links":{"self":{"href":"/example/bug","templated":false}}}

Expected Behaviour

The request should routed to the defined endpoint when the body can be mapped to the desired type. Here it is Object, but String and byte[] should also work.
I should not have to pass -H "Content-Type: */*" in my curl to get the response.

Actual Behaviour

Call is not routed to the desired endpoint.
I have to set the content-type of the request to */* to get it routed to the handler and get the desired response:

curl localhost:8080/example/bug --data 'foobar' -H "Content-Type: */*" 

Environment Information

  • Operating System: Mac OS Mojave 10.14.6
  • Micronaut Version: 1.2.6
  • JDK Version: Oracle JDK 11.0.2
@jameskleeh jameskleeh changed the title Route not matched for consumes=MediaType.ALL endpoints Body argument missing for consumes=MediaType.ALL endpoints Nov 13, 2019
@puneetbehl puneetbehl added status: pr submitted A pull request has been submitted for the issue and removed status: pr submitted A pull request has been submitted for the issue labels Nov 18, 2019
@fabienrenaud
Copy link
Contributor Author

Issue fixed with #2349
Added a test with #2369

@fabienrenaud
Copy link
Contributor Author

The issue still exist for HttpRequest argument: #2403

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

3 participants