{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/8441","repository_url":"https://api.github.com/repos/spring-projects/spring-boot","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/8441/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/8441/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/8441/events","html_url":"https://github.com/spring-projects/spring-boot/issues/8441","id":210981643,"number":8441,"title":"Multipart Form with Number @RequestPart causes HttpMediaTypeNotSupportedException","user":{"login":"browndogg33","id":2279382,"avatar_url":"https://avatars2.githubusercontent.com/u/2279382?v=3","gravatar_id":"","url":"https://api.github.com/users/browndogg33","html_url":"https://github.com/browndogg33","followers_url":"https://api.github.com/users/browndogg33/followers","following_url":"https://api.github.com/users/browndogg33/following{/other_user}","gists_url":"https://api.github.com/users/browndogg33/gists{/gist_id}","starred_url":"https://api.github.com/users/browndogg33/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/browndogg33/subscriptions","organizations_url":"https://api.github.com/users/browndogg33/orgs","repos_url":"https://api.github.com/users/browndogg33/repos","events_url":"https://api.github.com/users/browndogg33/events{/privacy}","received_events_url":"https://api.github.com/users/browndogg33/received_events","type":"User","site_admin":false},"labels":[{"id":297028791,"url":"https://api.github.com/repos/spring-projects/spring-boot/labels/status:%20feedback-provided","name":"status: feedback-provided","color":"fef2c0","default":false},{"id":293438798,"url":"https://api.github.com/repos/spring-projects/spring-boot/labels/status:%20waiting-for-triage","name":"status: waiting-for-triage","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-03-01T05:10:34Z","updated_at":"2017-03-02T04:09:36Z","closed_at":null,"body":"The following controller method causes a HttpMediaTypeNotSupportedException.  If I change the tenantId parameter to a String everything works fine.    \r\n\r\n```java\r\n@RequestMapping(value = \"/test\", method = RequestMethod.POST, consumes = {\"multipart/form-data\"})\r\n    public ResponseEntity<TemplateResponse> templatesPost(@RequestPart(value = \"tenantId\", required = true) Long tenantId,\r\n                                                          @RequestPart(value = \"file\", required = true) MultipartFile file,\r\n                                                          @RequestPart(value = \"subject\", required = true) String subject,\r\n                                                          @RequestPart(value = \"type\", required = true) String type) throws IOException {\r\n        Template template = new Template(tenantId, subject, type, file.getBytes());\r\n        TemplateResponse response = templateService.save(template);\r\n        return new ResponseEntity<>(response, HttpStatus.OK);\r\n    }\r\n```\r\nThis is the error response from Spring:\r\n\r\n```json\r\n{\r\n  \"timestamp\": \"2017-03-01T05:05:05.026Z\",\r\n  \"status\": 415,\r\n  \"error\": \"Unsupported Media Type\",\r\n  \"exception\": \"org.springframework.web.HttpMediaTypeNotSupportedException\",\r\n  \"message\": \"Content type 'application/octet-stream' not supported\",\r\n  \"path\": \"/notification/test\"\r\n}\r\n```\r\nI've tried wrapping the other params in an object, and I get the same response.  "},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/comments/283550905","html_url":"https://github.com/spring-projects/spring-boot/issues/8441#issuecomment-283550905","issue_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/8441","id":283550905,"user":{"login":"philwebb","id":519772,"avatar_url":"https://avatars2.githubusercontent.com/u/519772?v=3","gravatar_id":"","url":"https://api.github.com/users/philwebb","html_url":"https://github.com/philwebb","followers_url":"https://api.github.com/users/philwebb/followers","following_url":"https://api.github.com/users/philwebb/following{/other_user}","gists_url":"https://api.github.com/users/philwebb/gists{/gist_id}","starred_url":"https://api.github.com/users/philwebb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philwebb/subscriptions","organizations_url":"https://api.github.com/users/philwebb/orgs","repos_url":"https://api.github.com/users/philwebb/repos","events_url":"https://api.github.com/users/philwebb/events{/privacy}","received_events_url":"https://api.github.com/users/philwebb/received_events","type":"User","site_admin":false},"created_at":"2017-03-02T04:09:36Z","updated_at":"2017-03-02T04:09:36Z","body":"Change the ID `@RequestPart` to a `@RequestParam`\r\n\r\n```java\r\n@RequestParam(value = \"id\", required = true) String id\r\n```\r\n\r\nThis section of the JavaDoc explains more:\r\n\r\n> Note that `@RequestParam` annotation can also be used to associate the part of a \"multipart/form-data\" request with a method argument supporting the same method argument types. The main difference is that when the method argument is not a String, `@RequestParam` relies on type conversion via a registered `Converter` or `PropertyEditor` while `@RequestPart` relies on `HttpMessageConverters` taking into consideration the 'Content-Type' header of the request part. `@RequestParam` is likely to be used with name-value form fields while `@RequestPart` is likely to be used with parts containing more complex content (e.g. JSON, XML)"}}
{"actor":{"display_login":"philwebb"}}