Creating and activating users from the API

Hi there, we are using version 2.5.0.beta3 and are having some problems creating a user via the API.

We would like to create a user and be able to post a topic straight away using the API without them having to click the confirmation link in the email.

We have tweaked the Active flag in various ways when creating a user but cannot seem to remove the need for the confirmation email.

{"errors":["You are not permitted to view the requested resource."],"error_type":"invalid_access"}

1 Like

It looks like 2.5.0.beta3 was released on April 22, 2020 and the fix I made for this issue was released on April 14, 2020 so you should be able to create an active user via the API with a single request.

Can you verify your requests and response look similar to this curl command:

curl -i -sS -X POST "http://localhost:3000/users"  \
-H "Content-Type: multipart/form-data;"  \
-H "Api-Key: 079fb2bb12d3b436bb11bde8eb58aaa9a36560fa7d79b14b3087aa40b1ebc2c4"  \
-H "Api-Username: blake.erickson"  \
-F "name=8fe87241ca91a69f5ccd"  \
-F "username=8fe87241ca91a69f5ccd"  \
-F ""  \
-F "password=c9193506a8f5e402a88cf2f8cee3f258"  \
-F "active=true"  \
-F "approved=true"

HTTP/1.1 200 OK

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

Tried the curl command and the response shows user is not active. The message says the user will be activated through email.

C:\Windows\system32>curl -i -sS -X POST https://our-discourse-host/users -H "Content-Type: multipart/form-data;" -H "Api-Key: The-API-key" -H "Api-Username: The-username" -F "name=8fe87241ca91a69f5ccd" -F "username=8fe87241ca91a69f5ccd" -F "email=8fe87241ca91a69f5ccd@testemail.test" -F "password=c9193506a8f5e402a88cf2f8cee3f258" -F "active=true" -F "approved=true"
HTTP/1.1 200 OK
"message":"\u003cp\u003eYouΓÇÖre almost done! We sent an activation mail to \u003cb\u003e8fe87241ca91a69f5ccd@testemail.test\u003c/b\u003e. Please follow the instructions in the mail to activate your account.\u003c/p\u003e\u003cp\u003eIf it doesnΓÇÖt arrive, check your spam folder.\u003c/p\u003e",

@blake Could you please check post #3 and let me know if I am missing anything in there?