Skip to content

Instantly share code, notes, and snippets.

@nOy39
Created Aug 31, 2018
Embed
What would you like to do?
HttpMediaTypeNotSupportedException
@PostMapping(value = "image")
public void addImage(@RequestParam("file") MultipartFile file,
@RequestBody Workers workers) {
workers.setPhotoFile(utilService.createFileName(file));
workersRepo.save(workers);
}
Request URL: http://localhost:8080/api/image
Request Method: POST
Status Code: 415 Unsupported Media Type
Remote Address: 127.0.0.1:8080
Referrer Policy: no-referrer-when-downgrade
cache-control: no-cache, no-store, max-age=0, must-revalidate
connection: close
Content-Encoding: gzip
content-type: application/json;charset=UTF-8
date: Fri, 31 Aug 2018 11:32:38 GMT
expires: 0
pragma: no-cache
transfer-encoding: chunked
Vary: Accept-Encoding
x-content-type-options: nosniff
x-frame-options: DENY
X-Powered-By: Express
x-xss-protection: 1; mode=block
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7
Connection: keep-alive
Content-Length: 99091
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryno5Phpwy8QH26T6i
Cookie: Webstorm-1325cb19=4812f0b8-65d2-4cf6-94c5-6ce0afc9f55e
Host: localhost:8080
Origin: http://localhost:8080
Referer: http://localhost:8080/test
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
------WebKitFormBoundaryno5Phpwy8QH26T6i
Content-Disposition: form-data; name="file"; filename="191a37_2fa42012dfc14b6b9221b6ed02fa7036_mv2_d_1219_1300_s_2.png"
Content-Type: image/png
------WebKitFormBoundaryno5Phpwy8QH26T6i
Content-Disposition: form-data; name="workers"
[object Object]
------WebKitFormBoundaryno5Phpwy8QH26T6i--
[nio-8000-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'multipart/form-data;boundary=----WebKitFormBoundaryd1IpfF7AcVwMyFt8;charset=UTF-8' not supported
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment