API, create user, no longer returns user_id

I have a script that runs daily to create new users via the API. Up until a few days ago, when the post would complete, the response included the user_id of the newly created user. Now the API no longer does so? But the API docs indicate that it should.
https://docs.discourse.org/#tag/Users/operation/createUser

3 Likes

Is the user being created?

My guess is that for some reason the user isn’t being created and that’s why it’s not returning the user_id.

The users are getting created. I have confirmed. And the API gives back this status but it’s missing the user_id

{
    "success": true,
    "active": true,
    "message": "Your account is activated and ready to use."
}
2 Likes

Yeah. That seems like a bug, then. I looked for explanations in Commits · discourse/discourse · GitHub but didn’t find one.

To confirm the issue, I created a user through the API on 3.4.0.beta3-dev and it returned user_id in the response.

{
	"success": true,
	"active": true,
	"message": "Your account is activated and ready to use.",
	"user_id": 3
}

I did it again after upgrading to 3.4.0.beta4-dev and user_id is then missing:

{
	"success": true,
	"active": true,
	"message": "Your account is activated and ready to use."
}
1 Like

So you’ve narrowed down where the errant commit is.

1 Like

Just a hunch

probably related to DEV: Change hide_email_address_taken default to true (#30293) · discourse/discourse@c1c7ea8 · GitHub explained here:

I guess it would be desirable to override this behavior when it’s a request made using an admin API key?

5 Likes

Thank you! Changing that setting did restore the API result so that I get the user_id in the result after creating a user.

2 Likes