Discourse API docs mention a "request body" for a GET request

GET always has a query string and never has post data (that is why you are getting 413 payload too large, it does not expect any). When querying data from a server without making a change you’ll (almost) always use GET and not POST. So you should use params= instead of data=.

I think the docs for this specific API call are badly phrased (“Request Body schema” really indicates POST data) so I am moving this to bug and you don’t need to pay me anything.

import requests
import json

def get_post_from_topic(topic_id, post_id):
    endpoint = f"https://forum.example.com/t/{topic_id}/posts.json"
    api_username = 'system'
    api_key = 'REDACTED'
    headers = {
        "Content-Type": "application/json",
        "Api-Key": api_key,
        "Api-Username": api_username,
    }
    params = {
      "post_ids[]": post_id
    }
    response = requests.get(endpoint, headers=headers, params = params) 
    if response.status_code == 200:
        return response

response = get_post_from_topic(6,8)
print(response.json())

{"post_stream": {"posts": [{"id": 8, "name": "system", "username": "system", "avatar_template": "/images/discourse-logo-sketch-small.png", "created_at": "2022-06-26T04:44:23.637Z", "cooked": "<p><a name=\"collect\"></a></p>\n<h2>\n<a name=\"what-information-do-we-collectcollect-1\" class=\"anchor\" href=\"#what-information-do-we-collectcollect-1\"></a><a href=\"#collect\">What information do we collect...
5 Likes