Posting to sub category not working for me

Hi,

Using the following curl command to post to our forum from bash

curl -X POST -H "Content-Type: application/json" --data @/tmp/json.json "https://my.forum/posts?api_key=$API_KEY&api_username=$UN"

where json.json contains…

{
 "title": "test post",
 "category": "cat/subcat",
 "raw": "test post"
}

This works fine when sending to just a category, but when I try to send to a sub category, as shown above, the post is created without a category, so that everyone on the forum appears to see it

Anything special I need to set to get the post to correct be sent to a sub category

It’s best to use the category ID integer value as indicated by the docs here:
http://docs.discourse.org/#tag/Topics%2Fpaths%2F~1posts%2Fpost

This is untested by me but I believe you can also use the “subcat” without the prefix “cat/” however there may be some issue if you have categories / subcategories with the same names.

I would stick with integer category ID numbers.

4 Likes

Thanks, using the category ID numbers worked :slight_smile:

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.