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
for Rest API how can i change default response behaviour #3966
Comments
|
yes i did. what i understand is it will have type define and default is xml and json format. example in doc says that if in request format there is accept header of or if request url has parameter as now i also need this optional format like default format of xml/json as a data type flexible. But i dont find a way to set default format as i also check http://www.yiiframework.com/doc-2.0/guide-rest.html |
|
Hi i found one issue/limitation on what i am trying to achieve. code on and on now browser always send Now i am trying to get json in this request but can we have a way to modify this and set a default format priority along this this too. regards |
|
I don't think your request is realistic: your accept header contains |
|
Yes i understand but do you expect client will send Accept header in that case? now if it create / for Accept then what response will it provide? |
|
Also I dont know if i use Jquery to use rest API call then what Accept header browser will send? |
|
If the client does not provide You can specify headers when submitting ajax requests. |
|
In my opinion there should be a default response format. In my case i can clearly see that content negotiation not a solution which i think most of the user would like to use json. But we can still create our own class and override content negotiation. In my case i expect default response is json. if anybody what to get other then json formal then i will give other output as well. |
|
If you do not need content negotiation, then you can remove it and explicitly set the response format as The issue you described here is that the accept header says it wants |
|
well let put this in different way. Now same scenario if i request with parameter In my code if i explicitly set request parameter So my suggestion will be if you provide a default response format which can override the response format as you do in case of I believe very small line of code will implement this small improvement which might be a nice to have feature for developer / API developer. regards |
|
I don't think it makes sense to add this default format. As I said if you only want to support one format and would like to ignore |
Hi team,
I don't understand how can i change default response format? currenty it shows
XMLbut i want default API response behaviour asjsonAlso from doc it is not clear / not mention.
regards
Mithun Mandal
The text was updated successfully, but these errors were encountered: