I am trying to send JSON
via Postman to my aplication, but always getting error:
HTTP Status 405 ? Method Not Allowed
Message: Request method 'POST' not supported
Description: The method received in the request-line is known by the origin server but not supported by the target resource.
With csrf().disable()
in Spring Security config everything works fine.
I have simple rest
controller:
@RestController
@RequestMapping("/api")
public class CustomerRESTController {
@PostMapping("/customers")
public @ResponseBody Customer createNewCustomer(@RequestBody Customer customer) {
//...
return customer;
}
}
JSON
in Postman body (content type is set to JSON
, Method POST
: http://localhost:8080/api/customers/):
{
"firstName": "Testname",
"lastName": "Testlastname",
"email": "test@something.com"
}
Is there way how to use POST/PUT/DELETE
requests in Postman with csrf
enabled ?