Framework/Springboot

[Springboot] Http Status 415 error 였λ₯˜ (415 Unsupported Media Type)

yuri lee 2023. 1. 17. 23:18
λ°˜μ‘ν˜•

 

Intro

μ•ˆλ…•ν•˜μ„Έμš”. Springboot λ₯Ό μ‚¬μš©ν•˜λ˜ 도쀑 Http Status 415 error μ—λŸ¬κ°€ λ°œμƒν•˜μ˜€μŠ΅λ‹ˆλ‹€. 

 

415 Unsupported Media Type

Why?

κΈ°μ‘΄ μ»¨νŠΈλ‘€λŸ¬μ—μ„œ λ§€κ°œλ³€μˆ˜λ₯Ό λ°›κΈ° μœ„ν•΄ @RequestParam μ–΄λ…Έν…Œμ΄μ…˜μ„ μ‚¬μš©ν–ˆμŠ΅λ‹ˆλ‹€. λ§€κ°œλ³€μˆ˜ 5개λ₯Ό λ°›κ³  있던 터라 μƒλ‹Ήνžˆ λ³΅μž‘ν•΄ 보여 ν•΄λ‹Ή λ§€κ°œλ³€μˆ˜λ“€μ„ ν•˜λ‚˜μ˜ Dto Req 객체둜 λ°”κΏ”μ£Όμ—ˆμŠ΅λ‹ˆλ‹€. μ΄ν›„ μ½”λ“œ 싀행을 ν–ˆλŠ”λ°, λ‹€μŒκ³Ό 같은 μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.

 

Springboot λ₯Ό 잘 λͺ°λΌμ„œ, ν•΄λ§Έμ§€λ§Œ 저희에겐 κ΅¬κΈ€λ‹˜μ΄ μžˆμŠ΅λ‹ˆλ‹€. 🀧 !!

 

ꡬ글링 ν›„, μ œκ°€ μ‚¬μš©ν•œ μ–΄λ…Έν…Œμ΄μ…˜μ΄ 잘λͺ» λ˜μ—ˆλ‹€λŠ” 것을 μ•Œκ²Œ λ˜μ—ˆμŠ΅λ‹ˆλ‹€. @RequestParam λŠ” 단일 데이터λ₯Ό λ°›κΈ° μœ„ν•΄μ„œ μ‚¬μš©ν•˜κΈ° λ•Œλ¬Έμ—, λ‹€μŒκ³Ό 같이 μ—¬λŸ¬ λ§€κ°œλ³€μˆ˜κ°€ λ“€μ–΄μžˆλŠ” Dto 객체와 ν•¨κ»˜ μ‚¬μš©ν•  수 μ—†λ˜ κ²ƒμ΄μ—ˆμŠ΅λ‹ˆλ‹€. 

 

How to solve the problem

 @RequestParam μ–΄λ…Έν…Œμ΄μ…˜μ„ μ‚­μ œν•˜λ‹ˆ, 415 Unsupported Media Type 였λ₯˜κ°€ μ—†μ–΄μ‘ŒμŠ΅λ‹ˆλ‹€. 

 

Conclusion

μ–΄λ…Έν…Œμ΄μ…˜μ˜ μ“°μž„μƒˆλ₯Ό 잘 νŒŒμ•…ν•˜κ³  μ‚¬μš©ν•΄μ•Ό ν•  것 κ°™λ„€μš”! πŸ’¦

λ°˜μ‘ν˜•