fix(API): Send correct Content-Type with error entities

`rw.WriteHeader` was being called in `sendError` before the `Content-Type: application/json` was actually being set.