Sugar On-Demand: New User Creation via API

Hi,
    I am working on a client requirement that is to create new user in sugar on-demand via api.
I am trying to create user on my sandbox sugar via postman but i am getting not_authorized error. While if i do GET POST api calls to other module(Accounts,Contacts) i am getting results. 

Are there any cloud settings that need to set to enable user creation via api.

Please let me if anybody has any idea.

Regards,

Shameen

Parents
  • You need to set up an authentification call in postman to get an access token, this can be set up on the create call.

    The call should look something like:

    sugarurl/.../token

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    {
    "grant_type":"password",
    "client_id":"sugar",
    "client_secret":"",
    "username":"username",
    "password":"password"
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • i did create a token first and then used that token for further action. Same token worked for other modules but not for user creation. This is some permission issue, i need to know how can i get the access.

  • Is the auth- call setup on the create-call? or did you call it earlier and used the token?

    If you login with the user from the browser for example the token will be invalidated, could that be what's happening?

  • Did the auth call earlier and then used the token in the next call.

    i am making api calls using postman.
    I did auth call to sugar and got the token.
    Then used that token in my next api call for user creation in postman and got not_authorized error.

    While i do create new user within sugar it takes me to cloud settings and there i can do setup user fields.
    It looks like this needs to be something with cloud settings. or there migth be some other mechanism to create new users on sugar on-demand.

  • Can you paste the full error response? Sugar can throw different kind of errors with same error key - "not_authorized". The error description might be useful to understand what's happening.

    Also, just a quick re-check - are you a System Admin in your sandbox instance? 

  • Hi @Neeraja

    Here is the postman response.

    {
    "error": "not_authorized",
    "error_message": "You are not authorized to perform this action. Contact your administrator if you need access."
    }


    Yes i am using admin user but its not the super admin user. I am trying to get the creds for super admin so that i can check if i could do this with super admin user or not.

  • I'd say based on that response that your user is not allowed to create other users.


  • Another thing to check is - are you using Sugar Identity? You won't be able to create users via API if you have that enabled.

    This wiki page describes how to check if Sugar Identity is enabled - https://sugarclub.sugarcrm.com/dev-club/b/dev-blog/posts/what-you-need-to-know-about-the-new-sugaridentity-service

  • Well, yes i have checked Sugar Identity is enabled on this sugar instance.
    i think i may able to achieve my requirement via some custom api that will do direct db operation. 

    Thanks.

  • I am not sure if that is a good approach, that defeats the purpose of Sugar Identity :)

    https://support.sugarcrm.com/Documentation/SugarCloud_Services/SugarIdentity/SugarIdentity_Guide/#Best_Practices_When_Creating_Users

    You can also check with Sugar Support if there is an alternative "automated" way to create users in Sugar Identity. 

  • Thank Neeraja,

    Well that's also not do-able as that would create user in just sugar db, it wont be on cloud so i got error on seeing that db created record on cloud as it was not there.

    I need to know if we are able to create user with sugar identity programmatically.

Reply
  • Thank Neeraja,

    Well that's also not do-able as that would create user in just sugar db, it wont be on cloud so i got error on seeing that db created record on cloud as it was not there.

    I need to know if we are able to create user with sugar identity programmatically.

Children
No Data