Unable to correctly POST to `/api/dataset/json` (Solved)

I am trying use the /api/dataset/json api endpoint to get past the 2000 record limit. Using /api/datasetseems to work, but the json endpoint does not. I've tried to use the network connections tab in firefox to figure out what's going on, but I can't seem to get it.

Note: Table/column names are replaced

import requests
import pandas as pd
from typing import Any
from pydantic import BaseModel, Field
from dotenv import dotenv_values

class Mb_Client(BaseModel):
    url: str
    username: str
    password: str = Field(repr=False)
    session_header: dict = Field(default_factory=dict, repr=False)


    def model_post_init(self, __context: Any) -> None:
        self.get_session()


    def get_session(self) -> None:
        credentials: dict = {
            "username": self.username,
            "password": self.password
        }
        
        response = requests.post(
            f"{self.url}/api/session",
            json=credentials
        )

        session_id = response.json()["id"]
        setattr(self, "session_header", {"X-Metabase-Session": session_id})


    def post(self, api_endpoint: str, payload: dict) -> dict:
        post = requests.post(
            f'{self.url}/api/{api_endpoint}',
            headers = self.session_header | {
                "Content-Type": "application/json;charset=utf-8"
            },
            json=payload
        )
        return post.json()


def main() -> None:
    secrets: dict = dotenv_values()
    mb_client: Mb_Client = Mb_Client(
        url=f"{secrets['mb_url']}",
        username=secrets["username"],
        password=secrets["password"]
    )

    # NOTE: Working on /api/dataset
    # payload: dict = {
    #     "database": 4,
    #     "type": "native",
    #     "native": {
    #         "query": """
    #             SELECT *
    #             FROM "some_table" 
    #             WHERE "col1" = 'some_text'
    #               OR "col1" = 'some_other_text'
    #         """
    #     }
    # }
    # mb_data = mb_client.post("dataset", payload)["data"]

    
    payload: dict = {
        "query": {
            "type": "native",
            "database": 4,
            "native": {
                "query": """
                  SELECT * 
                  FROM "some_table" 
                  WHERE "col1" = 'some_text' 
                    OR "col1" = 'some_other_text'"""
            },
        }
    }


    print(mb_client.post("dataset/json", payload))

I had to use params= in the request and not json= as well as change the Content-Type header.

Working

import requests
import pandas as pd
from typing import Any
from pydantic import BaseModel, Field
from dotenv import dotenv_values
from json import dumps

class Mb_Client(BaseModel):
    url: str
    username: str
    password: str = Field(repr=False)
    session_header: dict = Field(default_factory=dict, repr=False)


    def model_post_init(self, __context: Any) -> None:
        self.get_session()


    def get_session(self) -> None:
        credentials: dict = {
            "username": self.username,
            "password": self.password
        }
        
        response = requests.post(
            f"{self.url}/api/session",
            json=credentials
        )

        session_id = response.json()["id"]
        setattr(self, "session_header", {"X-Metabase-Session": session_id})


    def post(self, api_endpoint: str, payload: dict) -> dict:
        post = requests.post(
            f'{self.url}/api/{api_endpoint}',
            headers = self.session_header | {
                # "Content-Type": "application/json;charset=utf-8"
                "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
            },
            # json=payload
            params=[("query", dumps(payload))]
        )
        return post.json()


def main() -> None:
    secrets: dict = dotenv_values()
    mb_client: Mb_Client = Mb_Client(
        url=f"{secrets['mb_url']}",
        username=secrets["username"],
        password=secrets["password"]
    )
    
    payload: dict = {
        "database": 4,
        "type": "native",
        "native": {
            "query": """
                SELECT *
                FROM "some_table"
                WHERE "col1" = 'some_text'
                    OR "col1" = 'some_other_text'
            """,
        },
    }

    print(mb_client.post("dataset/json", payload))


if __name__ ==  "__main__":
    main()