In a discussion regarding the Discourse API, cappslock reported an inconsistency where PUT requests to update topic tags fail with a 403 error unless the topic slug is included in the URL, whereas other methods like GET and DELETE function correctly with just the topic ID. While blake confirmed that using an incorrect slug still works, cappslock argued this is a bug rather than a feature, citing conflicting API documentation and inconsistent behavior across endpoints. Mittineague suggested it might be a routing requirement rather than a bug, but cappslock maintained that the inconsistency warrants a fix. Ultimately, sam agreed that while it does not strictly meet the definition of a bug, they are open to a PR to clean up the API and simplify the implementation.
Found this out while writing a request to change the tags on a topic.
Basically, this doesn’t work:
PUT /t/123.json?api_username=...&api_key=...
{
tags: ['a']
}
The server responds with:
403
{
"errors": [
"You are not permitted to view the requested resource."
],
"error_type": "invalid_access"
}
However, if you put the topic slug on the URL, everything works fine (i.e. PUT /t/why-arent-there-better-animals/123.json?api_username=...&api_key=...)
This is inconsistent with the other topic API methods which do not require a slug, and differs from the behavior described in the API documentation: Discourse REST API Documentation
Cela ne correspond pas à notre définition de Contribute > Bug, mais je suis tout à fait d’accord pour une PR qui nettoie cela, car cela simplifierait l’API.