# Discourse always posts in general using API

**URL:** https://meta.discourse.org/t/discourse-always-posts-in-general-using-api/70276
**Category:** Support
**Created:** [September 18, 2017, 2:23pm UTC](https://meta.discourse.org/t/discourse-always-posts-in-general-using-api/70276 "2017-09-18T14:23:36Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![dylanh724](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanh724/32/119642_2.png) [@dylanh724](https://meta.discourse.org/u/dylanh724)
#### Post date: [September 18, 2017, 2:23pm UTC](https://meta.discourse.org/t/discourse-always-posts-in-general-using-api/70276/1 "2017-09-18T14:23:36Z")

</div>

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):

 ![image](https://global.discourse-cdn.com/meta/original/3X/d/d/dda00d8039fed3099bbc09fc297e448253da5148.png)

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

---

<div class="post-metadata">

### Author: ![dylanh724](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanh724/32/119642_2.png) [@dylanh724](https://meta.discourse.org/u/dylanh724)
#### Post date: [September 18, 2017, 2:57pm UTC](https://meta.discourse.org/t/discourse-always-posts-in-general-using-api/70276/2 "2017-09-18T14:57:48Z")

</div>

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?](https://meta.discourse.org/t/improve-add-friendly-json-api-error-messages-at-least-generic-ones/70272) Seems a bit of a dramatic upgrade for such) and “15” as the category as a string.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [September 18, 2017, 4:34pm UTC](https://meta.discourse.org/t/discourse-always-posts-in-general-using-api/70276/3 "2017-09-18T16:34:41Z")

</div>

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

See also:

> [@Reverse engineer the Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576):
>
> Discourse is backed by a complete JSON api. Anything you can do on the site you can also do using the JSON api. The API is documented at [docs.discourse.org](https://docs.discourse.org). You can also use the [discourse\_api](https://github.com/discourse/discourse_api) Ruby gem as a client library. However, not every endpoint is documented. To determine how to do something with the JSON API here are some steps you can follow. Example: recategorize a topic. Go to a topic and start editing a category: Open Chrome dev tools, switch to the Network tab, select …

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [September 18, 2017, 8:01pm UTC](https://meta.discourse.org/t/discourse-always-posts-in-general-using-api/70276/4 "2017-09-18T20:01:44Z")

</div>

> [@riking](#):
>
> supporting the id was an accident

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

> [@Posting to sub category not working for me](https://meta.discourse.org/t/posting-to-sub-category-not-working-for-me/63462/2):
>
> It’s best to use the category ID integer value as indicated by the docs here:  
> [Discourse API Docs](http://docs.discourse.org/#tag/Topics%2Fpaths%2F~1posts%2Fpost)
> 
> …
> 
> I would stick with integer category ID numbers.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [October 5, 2019, 5:20pm UTC](https://meta.discourse.org/t/discourse-always-posts-in-general-using-api/70276/5 "2019-10-05T17:20:25Z")

</div>



---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [October 5, 2019, 9:53pm UTC](https://meta.discourse.org/t/discourse-always-posts-in-general-using-api/70276/6 "2019-10-05T21:53:48Z")

</div>

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](https://global.discourse-cdn.com/meta/original/3X/f/e/fe62eb393e68ae74246edc914ea7fa43dbe922f5.png)

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [October 5, 2019, 9:53pm UTC](https://meta.discourse.org/t/discourse-always-posts-in-general-using-api/70276/7 "2019-10-05T21:53:51Z")

</div>


