Added an JSON error instead of an HTML for API