Post a new Topic with REST - 403 Forbidden

api

(Aarskin) #1

Continuing the discussion from How can we create post/topic in Discourse using API:

I’m POST-ing the following URl from Advanced REST client and getting the same error.

http://[my discourse ip]/posts.json?title=“Created from the advanced REST client”&category=“2”&raw=“A whole bunch of text about a topic”&api_key="[key from admin tab]"&api_username="[admin username]"

I built up the URL by referencing this, [this] (How can we create post/topic in Discourse using API), and this (but I’m looking for a language agnostic solution). I’m hoping I missed something obvious.

Why am I getting a forbidden response as an admin user with an api key?

(Pointing me to How to reverse engineer the discourse api will not help me, I’ve read it twice)


How can we create post/topic in Discourse using API
(Aarskin) #2

It was something simple: I had quotation marks in my query string. Removing them solved my problem. I.e. I modified the query string in the original post to look like this:

http://[my discourse ip]/posts.json?title=Created from the advanced REST client&category=2&raw=A whole bunch of text about a topic&api_key=[key from admin tab]&api_username=[admin username]

… and got my 200 OK response! :smiley:

Still not clear why I was getting a permission error based on that mistake though.


How can I identify a topic created using the API?
(Jeff Atwood) #3

@techapj can you add to your list better error information when quotes are used around query string data in calling the API?