[API] POST /posts not working (since v2 upgrade ?)


(Shauni) #1

Hello there !

I’ve got a little problem : our backend is API-Connected with our Discourse instance, and use for example the POST /posts route to create new posts and topics.

Since v2 upgrade, the API does not accept any new request :frowning:

Here is an example POST request to create a new topic (api key and username are provided on the query string and are valid) :

 {
	"title":"Je suis un petit message de test",
	"topic_id": null,
	"raw":"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
	"category": 13
}

And here is the answer

 {
    "action": "create_post",
    "errors": [
        "Titre ne peut être vide",
        "Titre est trop court (le minimum est de 1 caractère)",
        "Titre ne semble pas clair, est-ce une phrase complète ?"
    ]
}

If all shown errors here are correct :

  • Title is correctly provided and not empty
  • Title is more than 1 char
  • Title answering to entropy settings

This exact same topic can be created without any problem on the Discourse itself.

Does API have changed since v2, and docs are not up-to-date ?
Do you have any answer to help us ?

Thanks a lot !


Recent changes to api requests?
(Simon Cossar) #2

I have tried to reproduce this. The /posts.json API endpoint is working correctly for me. The error messages that you are getting seem wrong for the parameters you are supplying. Could you try making the API request with Postman and see if it is still failing for you?