Question
AttributeError: 'NoneType' object has no attribute 'get' — with AttributeError
95ad8a32-59bd-44cd-af33-08670db6de1f
Flask API crashes with AttributeError: 'NoneType' object has no attribute 'get' when receiving API requests that don't contain valid JSON. The error occurs in POST/PUT endpoints that expect JSON data when trying to call .get() method on request.json, but request.json returns None when the client doesn't send proper JSON data or the Content-Type header is missing/incorrect.