1

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 ?

nehacharya
  • 925
  • 1
  • 11
  • 31
  • Does this answer your question? https://stackoverflow.com/questions/27182701/how-do-i-send-spring-csrf-token-from-postman-rest-client – jared Jun 14 '20 at 14:41

0 Answers0