Return JSON response for error

- Redirect on successful created document