Discourse always posts in general using API


(Dylan Hunt) #1

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


(Dylan Hunt) #2

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.


(Kane York) #3

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

See also:


(Dean Taylor) #4

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