Skip to content
This repository has been archived by the owner on Dec 28, 2020. It is now read-only.

[Yii 2.1] - Rest actions not setting headers right #1

Closed
johonunu opened this issue Mar 17, 2018 · 0 comments
Closed

[Yii 2.1] - Rest actions not setting headers right #1

johonunu opened this issue Mar 17, 2018 · 0 comments
Labels
Milestone

Comments

@johonunu
Copy link
Contributor

What steps will reproduce the problem?

Create REST controller with model and call create action.

What's expected?

Get "created" response.

What do you get instead?

Throws error.

Additional info

{
	"name": "Exception",
	"message": "Call to a member function set() on array",
	"code": 0,
	"type": "Error",
	"file": "/home/nikola/Projects/yii2.1/vendor/yiisoft/yii2-rest/src/CreateAction.php",
	"line": 56,
	"stack-trace": [
		"#0 /home/nikola/Projects/yii2.1/vendor/yiisoft/yii2/base/Action.php(94): yii\\rest\\CreateAction->run()",
		"#1 /home/nikola/Projects/yii2.1/vendor/yiisoft/yii2/base/Controller.php(157): yii\\base\\Action->runWithParams(Array)",
		"#2 /home/nikola/Projects/yii2.1/vendor/yiisoft/yii2/base/Module.php(528): yii\\base\\Controller->runAction('create', Array)",
		"#3 /home/nikola/Projects/yii2.1/vendor/yiisoft/yii2/web/Application.php(103): yii\\base\\Module->runAction('post/create', Array)",
		"#4 /home/nikola/Projects/yii2.1/vendor/yiisoft/yii2/base/Application.php(396): yii\\web\\Application->handleRequest(Object(yii\\web\\Request))",
		"#5 /home/nikola/Projects/yii2.1/public/index.php(11): yii\\base\\Application->run()",
		"#6 {main}"
	]
}

Calling inside "CreateAction" and "OptionAction":

$response->getHeaders()->set(...

Instead of:

$response->getHeaderCollection()->set(...
Q A
Yii version 2.1
Yii REST version
PHP version 7.2
Operating system Arch Linux
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants