'REST API How to generate a 500 Error status when using a Postman Request
I need to test the 500 'internal server error' but Need to test this new API with calls from postman. Does anyone know how to make a call that will trigger it? I'm not talking about setting up a mock or doing it from the dev side. I need to invoke 500 responses by making requests so I can verify that a 500 request is returned from this new server.
Solution 1:[1]
The 500 Internal Server Error is internal to your system and you will get it when there is some issue in your code.
If the code doesn't has issues and you just want to get a 500 error status for testing then you can throw an exception like NullPointerException from your code.
Solution 2:[2]
the 500 error can be get by not passing necessary parameter in header eg x-api-key and also incorrect data in request as not accepted by server eg name an be Name
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Deepak Patankar |
Solution 2 | mohd Bilal |