Creating new topic in subcategory via API

I tried using &category=subcategory-slug but it ends up in the uncategorized category. I also tried to use &category=category-slug/subcategory-slug and got the same thing. It works fine if it’s a main category. Is it possible to create a new topic in a subcategory? If yes, what’s the syntax?

Assuming the API takes the same parameters as create topic via URL (no idea why it wouldn’t) - then you should be using the category name, not the slug.

Source:
https://meta.discourse.org/t/cannot-compose-a-pre-filled-topic-via-url-when-subcategory-has-topic-template/39941/2?u=jomaxro

2 Likes

I just wanted to reply to say that I tried the category name too and that failed too. It had spaces (I used the url encoded version with both + and %20) but now I renamed it to something without spaces and it works. I then renamed it back to something with spaces and it still works … sorry for wasting your time :confused:

Based on the docs, the category parameter is an integer, you need to use the category id there.

http://docs.discourse.org/#tag/Topics%2Fpaths%2F~1posts%2Fpost

4 Likes

It certainly worked with the category name (string) though.