# API post request without an Accept header returns 406

**URL:** https://meta.discourse.org/t/api-post-request-without-an-accept-header-returns-406/175203
**Category:** Feature
**Created:** [January 5, 2021, 8:22pm UTC](https://meta.discourse.org/t/api-post-request-without-an-accept-header-returns-406/175203 "2021-01-05T20:22:50Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mbauman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mbauman/32/139835_2.png) [@mbauman](https://meta.discourse.org/u/mbauman)
#### Post date: [January 5, 2021, 8:22pm UTC](https://meta.discourse.org/t/api-post-request-without-an-accept-header-returns-406/175203/1 "2021-01-05T20:22:50Z")

</div>

[RFC 7231](https://tools.ietf.org/html/rfc7231#section-5.3.2) suggests that a request with a missing `Accept` header should be treated as `*/*`, but hitting the API POST endpoint for a [data explorer query](https://meta.discourse.org/t/how-to-run-data-explorer-queries-with-the-discourse-api/120063) without said header returns `406 Not Acceptable`. I’m not sure if this is specific to [data explorer](https://meta.discourse.org/t/32566?silent=true) or if it applies to other POSTs, too. All the other GETs I’ve used haven’t had this issue.

It so happens that `curl` and Python’s `requests` append `Accept: */*` to all their requests by default, but [not all tools do](https://github.com/JuliaWeb/HTTP.jl/issues/661). You can see this behavior by disabling `curl`’s default with an empty header, e.g.,

```plaintext
curl -X POST "https://discourse.example.com/admin/plugins/explorer/queries/26/run" \
-H "Content-Type: multipart/form-data;" \
-H "Api-Key: <your_all_users_api_key>" \
-H "Api-Username: system" \
-H "Accept:"

```

Not a major thing, but it might be something that other tools hit, too… and it seems like it could be a simple fix, especially since all other endpoints I’ve used work without it.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [January 7, 2021, 2:20am UTC](https://meta.discourse.org/t/api-post-request-without-an-accept-header-returns-406/175203/2 "2021-01-07T02:20:26Z")

</div>

This is very likely coming from the Rails stack (not Discourse), very likely complicated to work around.

I can see some assertions in actionpack for 406 status.

Going to recategorize this as #Contribute > Feature for now, since there is a trivial workaround and appears to be by design in Rails.
