That would work, but it actually said:
Bad csrf token when making api request
api_key and api_username are POST parameters, not headers.
so you can put the api_key and api_username in the POST body not in the header.
I must have linked to the wrong post. The one I read said that credentials could not be gleaned from the JSON payload, and you had to also include the api_key and api_username in the query string when using the .json endpoint. And it was only then that I managed to get a HTTP POST working for my bot.
Since it’s working that way I’m going to leave it like that for the moment though I should probably switch to using HTTPS.