Create Topic API Restrictions


(Spero Koulouras) #1

I am able to use the create topic API to create simple text messages and push them into my Discourse instance. If I want to create richer messages containing links, images or other HTML what are the restrictions? I have already found that including image URL’s with imgur links causes the API to return a 400 (Bad Request) error. Are there other restrictions on HTML Tags that may also cause problems? Is the HTML whitelist applied on the server side of these API’s? How much must I sanitize?

The use case here is creating new topics from a structured page on our web site, not from within the forum itself.


(Jeff Atwood) #2

I am guessing your content encoding code is not correct. You can enter anything you would in a normal post.


(Spero Koulouras) #3

Thanks. Problem was with nested quotes within the tag.

So the remaining questions are:

  1. Do I need to sanitize on my client side (which I would normally do as a matter of course)

  2. Is there anything within a properly encoded body that will make Discourse urp that should be parsed out on the front-end.


(Kane York) #4

No need to sanitize, that’s done by the server. All you need to take care of is properly HTML-encoding the request.

Any post content that makes Discourse error is a bug.


(Spero Koulouras) #5

Thanks - that is the perfect answer.