Troubles creating users via API calls

I’m trying to create a new user via API calls. My code is mostly working, in that it manages to create the user and it manages to add the user to a specific group, but the newly created user is disabled in keycloak and the credentials aren’t being saved, as you can see in the screenshots here below.

kccred

Here is the sequence of API calls I make (cut and pasted from the output of console.log()):

URL: https://localhost:8080/admin/realms/MyRealm/users
options: {"headers":{"Authorization":"Bearer ey...","Content-Type":"application/json"},"method":"POST","body":"{\"email\":\"marioross12i@example.com\",\"username\":\"mariorossi12\",\"attributes\":{\"provisioned\":true},\"credentials\":[{\"secretData\":\"changeme\",\"temporary\":true}]}"}

URL: https://localhost:8080/admin/realms/MyRealm/attack-detection/brute-force/users/fe3d9e63-cd24-423f-a620-2027f907a9ca
options: {"headers":{"Authorization":"Bearer ey...","Content-Type":"application/x-www-form-urlencoded"},"method":"DELETE"}

URL: https://localhost:8080/admin/realms/MyRealm/users/fe3d9e63-cd24-423f-a620-2027f907a9ca/groups/97788f9e-a113-420b-a629-ad39e5d70f09
options: {"headers":{"Authorization":"Bearer ey...","Content-Type":"application/x-www-form-urlencoded"},"method":"PUT"}

I’m using KC 22.0.3.

What am I doing wrong? How should I make the calls in order to have the user enabled and the credentials saved?

I got an answer here.