I’m currently writing some simple PHP using CURL to invite users to our discourse forum from another system.
Whenever the /invites endpoint is POSTed the expected data, I get a JSON encoded response of success: OK and the expected HTTP 200 response.
Whenever I submit a email on a blacklisted domain which should get me a HTTP 422 response from the server I get nothing but the HTTP 422 response back. This is both from CURL and testing via postman.
From my testing the /invites endpoint returns 422 when an invite has already been accepted or when you’re trying to invite a user to a domain you’ve blacklisted in the email domains blacklist. I need to let the end-user know which of these it was so they know why it failed.
This is happening on the most recent commit as well as the commit we’ve been running on for a few months - I did a rebuild to be sure it wasn’t something weird.
Every 422 response in the invites controller I can see renders a JSON response. Can you give a small, self-contained example of how to reproduce this behaviour that we can run against a local dev instance of Discourse?
Had to split the post because it seems I haven’t posted here enough to put two in an image
Our discourse yaml config is the standard standalone except we’ve added a couple of env variables to the docker container so that nginx-proxy and an nginx-proxy letsencrypt helper in other docker containers can work.
Sorry, final addendum but when I POST an email that already exists as a user I get a JSON formatted response correctly. So this appears to be only relating to domains that are blacklisted.
Assume I don’t have this Postman tool you speak of. How can I replicate this using tools that are available in or alongside a Discourse installation (such as curl)? A single curl command sounds like it should be capable of triggering this.
OK, I can reproduce this on try using the curl command you gave. The code still doesn’t look like it should ever be flinging back a 422 with a HTML response, but I see @techAPJ is on the case, so I’m sure he’ll figure it out quickly enough.