Difficult to work out reason for Http 422 error in api

I am running a test import of topics into discourse, for some topics I get error 422. I understand this basically means the syntax of the request is fine but there is something wrong with the data, but it doesn’t tell you what is wrong with the data making it difficult to work out

For example I spent ages trying to work out what was wrong with one topic, and because the body of the message was quite long and there were various punctuation characters I thought the problem might be with them, so I kept cutting it down and down and it made no difference.

Eventually I worked out it was because the topic title was too short as the default minimum was 15, and mine was 13, so I amended some values in settings, but much better if the api told me (or maybe it does and I missed it)

I currently have problem with the topic creation below, I can see nothing unusual about it, and category id is valid, any ideas ?

SEVERE: RESPONSE_CODE:422:REQUEST_JSON:{"title":"Urgent Jaikoz 1.9.2:Released","raw":"There was still a problem outstanding with the previous release with regards to MusicBRainz functionality, please update immediately.\r\n\r\nMore details at http://www.jthink.net/jaikoz/jsp/news/start.jsp ","category":1358,"created_at":"2007-05-24 10:06:20"}
4 Likes

In this case found the problem the title was a duplicate title (after stripping of a trailing blank). I guess the process is to manually create in User Interface and see what happens

5 Likes

When publishing posts to Discourse with the API, you can set the skip_validations parameter to true to avoid 422 errors for posts that would be disallowed by your site’s settings.

5 Likes

That is great, thankyou.
But wish I had known about this before, is it documented at https://docs.discourse.org/ I can’t see it ?

3 Likes

No, but I will add it there.

5 Likes

Confirmed that does indeed work

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.