Create New User through API

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • nicko
    replied
    Hey, thanks for checking, I've tried with that JSON but it's still 403. I also checked and if I intentionally make the JSON invalid I get a 500 as expected. What did you have to do on Espo to allow an API call to create a user?

    Leave a comment:


  • emillod
    replied
    Your request is bad. Please try this: https://dubas.pro/c/?5779a0d11efc1f7...kBFtQ1LiECpc64

    Leave a comment:


  • nicko
    replied
    Yep sure, I'll attach a pic of the API from Integromat, and the JSON I'm sending is below.

    {"type":"regular","firstName":"s34dsdf","lastName" :"w34erwerwe","isActive":true,"teams":{"teamsId s":[]},"gender":"","userName":"s34dfsdf@sdfsdf4747sd.co m","emailAddressData":[{"emailAddress":"s34dfsdf@sdfsdf4747sd.com","prima ry":true,"optOut":false,"invalid":false,"lower":"s 34dfsdf@sdfsdf4747sd.com"}],"emailAddress":"s34dfsdf@sdfsdf4747sd.com","email AddressIsOptedOut":false,"salutationName":null,"ro lesIds":["5ed4f6eec92414251"],"rolesNames":{"5ed4f6eec92414251":"Full User Access"},"password":"e76jcP3Uga","passwordConfirm" :"e76jcP3Uga","passwordPreview":"e76jcP3Uga","send AccessInfo":true,"title":null,"phoneNumberData":[],"phoneNumber":null,"phoneNumberIsOptedOut":null," teamsIds":[],"teamsNames":{},"teamsColumns":{},"defaultTeamNam e":null,"defaultTeamId":null}

    Leave a comment:


  • emillod
    replied
    Originally posted by nicko
    Thanks for the reply

    Yep that is the correct - I have a Role assigned to the API user that has Users: Create:yes, Read: all, Edit: all, Delete: all. I can verify the role is taking affect as if I change the Read permission to no and then attempt a GET, it fails with a 403, then if I switch Read back to all, it returns users ok.

    Should this "just work" based on just modifying the scope User.json file and then updating the Role to include Create: yes
    Could you show your request?

    Leave a comment:


  • nicko
    replied
    Thanks for the reply

    Yep that is the correct - I have a Role assigned to the API user that has Users: Create:yes, Read: all, Edit: all, Delete: all. I can verify the role is taking affect as if I change the Read permission to no and then attempt a GET, it fails with a 403, then if I switch Read back to all, it returns users ok.

    Should this "just work" based on just modifying the scope User.json file and then updating the Role to include Create: yes

    Leave a comment:


  • emillod
    replied
    Originally posted by nicko
    Hi guys, did you manage to successfully create a user via an API call? I'm not that great at PHP and JSON but it looks like the structure of EspoCRM has changed a lot in v7 onwards (I'm running 7.0.9), so i think some of the steps in the older posts on this forum no longer work for this. I've followed the steps to modify the User.json in Scope to give me access to assign Create permissions for User in role I can then assign to an API user, and I know the API user is good as I can successfully execute a GET to return users. However whenever I try a POST to create a user via an API call I get the 403 error and debug logs confirm it's failing on create.

    [2022-02-09 20:55:34] NOTICE: (403) No create access.; POST /User; line: 632, file: /var/www/html/application/Espo/Core/Record/Ser
    vice.php..................

    I'm totally stuck after several days of digging around trying to make this work so if you could share the steps you had success with that would be awesome!
    You have to give user which you use to connect through api permission to create users. Go to Administration -> Roles

    Leave a comment:


  • nicko
    replied
    Hi guys, did you manage to successfully create a user via an API call? I'm not that great at PHP and JSON but it looks like the structure of EspoCRM has changed a lot in v7 onwards (I'm running 7.0.9), so i think some of the steps in the older posts on this forum no longer work for this. I've followed the steps to modify the User.json in Scope to give me access to assign Create permissions for User in role I can then assign to an API user, and I know the API user is good as I can successfully execute a GET to return users. However whenever I try a POST to create a user via an API call I get the 403 error and debug logs confirm it's failing on create.

    [2022-02-09 20:55:34] NOTICE: (403) No create access.; POST /User; line: 632, file: /var/www/html/application/Espo/Core/Record/Ser
    vice.php..................

    I'm totally stuck after several days of digging around trying to make this work so if you could share the steps you had success with that would be awesome!

    Leave a comment:


  • emillod
    replied
    Originally posted by MrThiemann
    I also dealt with api users a little earlier. In any case, I created a separate role for the api user and activated "Webhooks". and of course users...
    Imho there is no need to activate webhooks in this case

    Leave a comment:


  • MrThiemann
    replied
    I also dealt with api users a little earlier. In any case, I created a separate role for the api user and activated "Webhooks". and of course users...

    Leave a comment:


  • mkas
    replied
    Thanks.

    Leave a comment:


  • emillod
    replied
    If you want to create user you have to use POST, not PUT. You have to create new role for API user and in this user allow for Users creation.
    Then create new API user and assign role to this user https://i.imgur.com/8r9lLVj.png

    Leave a comment:


  • mkas
    replied
    I have had success by creating an admin user with just create access.
    Is this the best way to achieve this?

    Leave a comment:


  • mkas
    started a topic Create New User through API

    Create New User through API

    HI there,

    I have read all the documentation and still struggling on how to create a new user using only API calls.
    I know that I need to PUT data into the users table, but there is no permission in the role editor for me to give 'Users Create' to my API user.

    Any thoughts? Thanks heaps.
Working...