Skip to content
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

REST-API: create/update should return success state / no redirect #16

Closed
derkra opened this issue Sep 24, 2012 · 2 comments
Closed

REST-API: create/update should return success state / no redirect #16

derkra opened this issue Sep 24, 2012 · 2 comments

Comments

@derkra
Copy link

derkra commented Sep 24, 2012

Each REST-Controller for post/put (repective create/update) ends with this code:

$this->View()->assign(array('success' => true, 'data' => $data));
$this->Response()->setHeader('Location', $location);

Please remove the last line. Returning the json-response ist a better way for the REST-client to determine if the action was successful.

@bcremer
Copy link
Contributor

bcremer commented Sep 25, 2012

Hi, thanks for your input.

It's good practise to specify the URI of a newly created resource in the Location response header.

I don't see any drawbacks for including the location header.

@derkra
Copy link
Author

derkra commented Sep 25, 2012

Hello,

ok, researching on this topic, you are right!
A location header does not alway mean a redirect. The statuscode is ok (200) on success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants