Hmm, your curl request worked for me when it was sent as a post request and the topic-id adapted to this topic (13926). Your API key is also active. Let me know the error if it’s not working.
after reading some discussions I understand that the topic_id parameter is optional, for adding a post to an existing topic. if not present, it should create a new topic - this was how the form was intended to work (see an example response here)
Regardless when including topic_id or only the category_id to post in, both return the 403 error.
The body payload is like this:
var payload = {
title: 'Rethinking retirement - response by owen',
raw: 'test_post 1',
category: 237
};
So it should post a new topic in category 237 (campfire).
@gdpelican may be able clarify how this should work, if available.
Update - in this example, different header parameters are used:
curl -X POST "https://my.discourse.com/posts" \
-H "Content-Type: multipart/form-data;" \
-F "api_key=theGeneratedAPIKeyForanAdmin" \
-F "api_username=anAdmin" \
-F "title=This is an API created topic" \
-F "raw=This is the end of the world as we know it, and I feel fine."
The two parameters api_key and api_username are not in the header of the form’s call, only Api-Key - so I will test with these two.
Found this Discourse REST API Documentation - developers - Discourse Meta - all non-HTTP header based authentication was dropped. So the right way to do it is to supply the API-Key in the header. Does a curl request work for you - or do you always get 403 errors?
Now when I use a user created by means of the API I also get this error. No idea why - as creating posts shall be allowed based on the access rights. I’ll look into it.
@owen Now it should finally work. There was a bug in Discourse which we fixed some time ago but now Discourse fixed it as well in the new release and we had to fix our bugfix.