# Improve BAD CSRF error message when making API calls with content-type application/json

**URL:** https://meta.discourse.org/t/improve-bad-csrf-error-message-when-making-api-calls-with-content-type-application-json/117136
**Category:** Development
**Created:** [May 8, 2019, 1:14am UTC](https://meta.discourse.org/t/improve-bad-csrf-error-message-when-making-api-calls-with-content-type-application-json/117136 "2019-05-08T01:14:42Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![nylen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nylen/32/125684_2.png) [@nylen](https://meta.discourse.org/u/nylen)
#### Post date: [September 14, 2020, 7:13pm UTC](https://meta.discourse.org/t/improve-bad-csrf-error-message-when-making-api-calls-with-content-type-application-json/117136/8 "2020-09-14T19:13:10Z")

</div>

We were seeing this error after a recent Discourse upgrade (within the last few months). The application was not authenticating against the API via the HTTP headers, changed it to do so and now it works again.

---

_[View the full topic](https://meta.discourse.org/t/improve-bad-csrf-error-message-when-making-api-calls-with-content-type-application-json/117136)._
