Discourse always posts in general using API

Whenever I post via the API, I tested it in Postman and it sends the right things to the right category.

However, when I more or less copy+paste the same thing with an http POST (via JavaScript), I get everything right…EXCEPT the category (which I thought was the easiest part):

I’m just truly stumped. Does anyone have any ideas as to why this wouldn’t send to the correct category?

  • I’m posting it as a FORM data (and not JSON, like Postman/tutorial says to do)
  • No special headers - it’s pretty vanilla
  • I copy+pasted “category” to ensure I didn’t typo it (shown in screenshot). It IS an number, right? I’m about to try it as text

UPDATE:

It IS an number, right? I’m about to try it as text

Error 422 when I try it as string. It is definitely a number.

UPDATE 2:

Wait a sec… I’m still getting 422 errors even when account is admin? I guess this is for a new post

Ahhhh apparently error 422 is rate-limiting. The category “number” IS actually “text” (a string). Making bot account admin seemed to do the trick for the limiting (…but why do I have to make it an ADMIN to edit rate limiting? Seems a bit of a dramatic upgrade for such) and “15” as the category as a string.

1 Like

I believe the browser client submits the category as its name; supporting the id was an accident.

See also:

2 Likes

If it was an accident - that sounds a little cray-cray…

2 Likes

Just wanted to clarify that when creating a topic in a category via the API, you specify the category by id now, not by name.

image

3 Likes