-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Formatter for: "content-type: application/json" #977
Comments
I think that you have an error and the Exception is not getting the Accept Header. You could try send it or, please, debug for this lines: https://github.com/bcit-ci/CodeIgniter4/blob/41f90ecae7fc3f8d9740c47a78a441f57d61dbd3/system/Debug/Exceptions.php#L147-L152 |
I add
and post that json again, it was my fault with routes. Thx for hint, sorry for that, everything is working gr8. |
Oh, that's good you can solve. Even so, it looks like we should do something to respond a generic format without the Accept Header. Checking the Content-Type also, maybe. |
I think you could just look for other the most popular content types provided by 'accept' header and return stack trace as JSON or XML or just return simple preformated text. I think it will be the simplest improvement for that, I am not sure if it can be treated as issue. May I help you with that case somehow? |
@nowackipawel Could you provide steps to reproduce this from a new install? I just tried a GET request to the home page with no headers at all and it worked as expected. |
I've checked it now and it seams to work good.
accept: application/xml works good as well :). |
Glad to hear it's working now! Closing. |
I am trying to use CI4 for an API and I am sure that thing was working in some of previous versions.
My request header is:
content-type:
application/json
I am getting error:
<br /> <b>Fatal error</b>: Uncaught InvalidArgumentException: No Formatter defined for mime type: in /home/.../site/application/Config/Format.php:56 Stack trace: #0 /home/.../site/system/API/ResponseTrait.php(358): Config\Format->getFormatter('') #1 /home/.../site/system/API/ResponseTrait.php(120): CodeIgniter\Debug\Exceptions->format(Array) #2 /home/.../site/system/Debug/Exceptions.php(149): CodeIgniter\Debug\Exceptions->respond(Array, 500) #3 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(Error)) #4 {main} thrown in <b>/home/.../site/application/Config/Format.php</b> on line <b>56</b><br /> <br /> <b>Fatal error</b>: Uncaught InvalidArgumentException: No Formatter defined for mime type: in /home/.../site/application/Config/Format.php:56 Stack trace: #0 /home/.../site/system/API/ResponseTrait.php(358): Config\Format->getFormatter('') #1 /home/.../site/system/API/ResponseTrait.php(120): CodeIgniter\Debug\Exceptions->format(Array) #2 /home/.../site/system/Debug/Exceptions.php(149): CodeIgniter\Debug\Exceptions->respond(Array, 500) #3 /home/.../site/system/Debug/Exceptions.php(201): CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException)) #4 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler() #5 {main} thrown in <b>/home/.../site/application/Config/Format.php</b> on line <b>56</b><br />
When I add an print $mime in this function it prints : undefined
The text was updated successfully, but these errors were encountered: