1

As far as I understand, POST parameters can be sent using Content-Type only either multipart/form-data or x-www-form-urlencoded. Is that right? I want to send the parameters wrapped in JSON. Is that possible? Will the parameters in the request

POST /login HTTP/1.1
Host: localhost:8080
Content-Type: application/json

{"username": "test","password": "test"}

be identified as username=test&password=test?

banan3'14
  • 3,810
  • 3
  • 24
  • 47
  • Spring Framework doesn't seem to identify such parameters, that is the reason why I'm asking the question. – banan3'14 Aug 26 '18 at 22:35
  • An HTTP POST can be sent [with 'any' Content-Type](https://tools.ietf.org/html/rfc7231#section-3.1.1.5); such a Content-Type restriction *might* come different HTML/browser/etc contexts, but it's *not* an HTTP restriction. – user2864740 Aug 26 '18 at 22:37
  • It's probably the case that the application/Spring "hasn't been setup" to correctly work with such an incoming encoding - eg. https://stackoverflow.com/questions/18550418/json-post-to-spring-controller , https://www.leveluplunch.com/java/tutorials/014-post-json-to-spring-rest-webservice/ (try some research, there are very few new snowflakes.. and "posting JSON to Spring" is a thing) – user2864740 Aug 26 '18 at 22:38
  • `Content-Type` can be sent as `application/json`, You can check out this [answer](https://stackoverflow.com/a/477819/10109833) – moebius Aug 27 '18 at 01:34

0 Answers0