403 Forbidden vs 401 Unauthorized HTTP responses

A clear explanation from Daniel Irvine: There’s a problem with 401 Unauthorized, the HTTP status code for authentication errors. And that’s just it: it’s for authentication, not authorization. Receiving a 401 response is the server telling you, “you aren’t authenticated–either not authenticated at all or authenticated incorrectly–but please reauthenticate and try again.” To help you … Read more

How do I POST JSON data with cURL?

You need to set your content-type to application/json. But -d (or –data) sends the Content-Type application/x-www-form-urlencoded, which is not accepted on Spring’s side. Looking at the curl man page, I think you can use -H (or –header): -H “Content-Type: application/json” Full example: curl –header “Content-Type: application/json” \ –request POST \ –data ‘{“username”:”xyz”,”password”:”xyz”}’ \ http://localhost:3000/api/login (-H … Read more