SOLVED: API create post: get 400: "Invalid post parameter [details: ]"

I’m trying to programmatically post some messages to a channel using the API.

My script can get authorised, use the Bearer token to do GET requests on the API, but when I try to POST a message to the channel, I get this rather unhelpful failure.

I can’t tell from that whether it’s failing because:
a) it doesn’t see the post data I’m sending;
b) there’s an invalid param in what I’m sending,
c) there’s a necessary param missing from what I’m sending
d) something else.

If any kind soul could send me a working example of a CURL command used to do a POST of a message to a channel via the API (note, API, not webhook), I’d really appreciate it.

Or give me a pointer to how to debug this…

thanks
Rachel

Replying to my own post… I’ve got a working version now. It looks like a combination of :

  1. you need a “Content-Type: application/json” header
  2. I was just sending bad JSON