API create topic bug


(Ahmad Mushtaq) #1


So I have a category tv and then I have two other categories comedy and hh whose parent category is tv. I am using API to create topics under comedy and hh. I observe that while create topic is able to create a new topic successfully. however only for the category of comedy the new topic is correctly categorized, for when using the category hh, the new topic has no category associated with it.

I am using someones nodejs port of the discourse api ruby gem which is here: GitHub - digitalsurgeon/discourse-api: Node wrapper for the Discourse API

I can only conclude that there is something going wrong in the discourse server side somewhere, how can I fix this ? and pointers ? how can I debug this ?


(Sam Saffron) #2

Remember, our website also consumes the discourse api, for this to be a bug it will also need to be present when creating topics via the web.
use chrome dev tools while creating a topic, compare to the payload you are sending direct via the api.

(Ahmad Mushtaq) #3

Yes, I followed your advice and here is what I discovered: the discourse web uses category ids when creating a topic, for example for the category hh the id is 9. when I am using the api myself to create the topic under hh using the category id as a parameter, it works. but not when the category slug. however when i create a topic under the category of comedy (slug: comedy) then just using the slug itself works. anyways I will leave it at this.

perhaps there is still an issue in discourse somewhere, but for now using the category id is enough for me.

thanks @sam