Skip to content

Commit

Permalink
Specify content-type header requirement (#7289)
Browse files Browse the repository at this point in the history
* specify content-type header

* stab
  • Loading branch information
bsian03 authored Nov 26, 2024
1 parent 5f58209 commit 9c4fa36
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/Reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ Clients may append more information and metadata to the _end_ of this string as
> warn
> Client requests that do not have a valid User Agent specified may be blocked and return a [Cloudflare error](https://support.cloudflare.com/hc/en-us/articles/360029779472-Troubleshooting-Cloudflare-1XXX-errors).
### Content Type

Clients using the HTTP API must provide a valid `Content-Type` header, either `application/json`, `application/x-www-form-urlencoded`, or `multipart/form-data`, except where specified. Failing to do so will result in a `50035` "Invalid form body" error.

### Rate Limiting

The HTTP API implements a process for limiting and preventing excessive requests in accordance with [RFC 6585](https://tools.ietf.org/html/rfc6585#section-4). API users that regularly hit and ignore rate limits will have their API keys revoked, and be blocked from the platform. For more information on rate limiting of requests, please see the [Rate Limits](#DOCS_TOPICS_RATE_LIMITS/rate-limits) section.
Expand Down
3 changes: 3 additions & 0 deletions docs/events/Webhook_Events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ If either of these are not complete, your Webhook Events URL will not be validat

When adding your Webhook Events URL, Discord will send a `POST` request with a `PING` payload with a `type: 0` to your endpoint. Your app is expected to acknowledge the request by returning a `204` response with an empty body.

> info

This comment has been minimized.

Copy link
@leydel

leydel Nov 26, 2024

Contributor

This expects a 204 response and with no content there shouldn't be a content type. Api quirk of documentation error?

> You must provide a valid `Content-Type` when responding to `PING`s. See [here](#DOCS_REFERENCE/http-api) for further information.
<Collapsible title="Responding to PING Requests" description="Code example for acknowledging PING events" icon="code">
To properly acknowledge a `PING` payload, return a `204` response with no body:

Expand Down
3 changes: 3 additions & 0 deletions docs/interactions/Overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ If either of these are not complete, your Interactions Endpoint URL will not be

When adding your Interactions Endpoint URL, Discord will send a `POST` request with a `PING` payload with a `type: 1` to your endpoint. Your app is expected to acknowledge the request by returning a `200` response with a `PONG` payload (which has the same `type: 1`). Details about interaction responses are in the [Receiving and Responding documentation](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING).

> info
> You must provide a valid `Content-Type` when responding to `PING`s. See [here](#DOCS_REFERENCE/http-api) for further information.
<Collapsible title="Responding to PING Requests" description="Code example for acknowledging PING interactions" icon="code">
To properly acknowledge a `PING` payload, return a `200` response with a payload of `type: 1`:

Expand Down
3 changes: 3 additions & 0 deletions docs/interactions/Receiving_and_Responding.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ Now that you've gotten the data from the user, it's time to respond to them.

Interactions--both receiving and responding--are webhooks under the hood. So responding to an Interaction is just like sending a webhook request!

> info
> Interaction responses have the same header requirements as normal HTTP API requests. See [here](#DOCS_REFERENCE/http-api) for further information.
There are a number of ways you can respond to an interaction:

### Interaction Response Object
Expand Down

0 comments on commit 9c4fa36

Please sign in to comment.