-
Notifications
You must be signed in to change notification settings - Fork 46
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
PUTting a resource always returns Content-Type "text/html" #12
Comments
I think yould see on the configuration of fosrest on the format type part https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Resources/doc/configuration-reference.md |
I'm having this same problem, did you find a solution? |
This is an old topic, but I am getting the same errors. Did you find a solution? |
Update: Tried returning a view object directly. It still gets converted to text/html even when I explicitly set headers to application/json. I have no idea what is going on... I have never been using Symfony before and I am still experimenting, but I might have found the source of the issue, but no real solution yet. By forcing redirects also for json I am getting the correct content type (but then the wrong status code).
This leads me to believe something bad happens when the redirect in the PageController does not redirect because we are requesting a json reply. For instance:
This appears to be related: |
A few hours into debugging now.. a little wiser. It appears that the PUT request is correctly setting content headers as long as the http response code is anything but 204. This is caused by PHP or your web server, see the two links below for explanations. See here: symfony/symfony#12744 I am still trying to figure out what response to return, but I will very probably do something along the lines of this:
Key here is that html is being rerouted, while any other format is provided with a response header with the address of the resource in the location header. What led me to this is mainly. |
Hello.
I'm trying to implement a new REST API in my project, but I'm getting the same errors I get when I test
liuggio/symfony2-rest-api-the-best-2013-way
: thePUT
HTTP calls are always returned astext/html
(instead ofapplication/json
), and fail in theassertJsonResponse
assertion. The other methods always returnapplication/json
.Did anyone have the same problem?
The text was updated successfully, but these errors were encountered: