Skip to content

401 error in cloudstack createUser rest api #11130

Closed

Description

@waiphyodev

Hi,

My cloudstack api url for create user is like

http://cloudstack-host/client/api?account&command=createUser&email=userthree%40mail.com&firstname=User&lastname=Three&password=password&response=json&username=userthree&signature=

It rejects me with 401
It is happening only in createUser and createAccount APIs
If someone know what is happening here, I really appreciate for your help

Thanks,

Activity

  1. boring-cyborg commented on Jul 3, 2025

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template!

  2. DaanHoogland commented on Jul 3, 2025

    @DaanHoogland
    Contributor

    @waiphyodev , I suppose you left out the signature on purpose and did include it in your attempts to create a user.
    there is “account” between the URL and the rest of the parameters,
    my try looks like

    http://host/client/api/?command=createAccount&response=json&sessionkey=… 
    

    and is a post request with parameters.

    roleid=<role-id>&username=userthree&password=password&email=userthree%40mail.com&firstname=User&lastname=Three&domainid=<domain-id>
    

    if this seems ok,
    Have a look at the rights of the executing user, Do they have rights to this API.

  3. waiphyodev commented on Jul 4, 2025

    @waiphyodev
    Author

    Thanks for reply.
    Yes, it does have required permissions to do request because I do the same process via CloudStack dashboard with the same account and it is fine.
    This is happening only via API.
    What if I'm calling with API key, how should I give payload in which method.

  4. waiphyodev commented on Jul 4, 2025

    @waiphyodev
    Author

    GET (401 error)
    http://host/client/api?apikey=<api-key>&command=createAccount&domainid=<domain-id>&email=userthree%40mail.com&firstname=User&lastname=Three&password=password&response=json&roleid=<role-id>&username=userthree&signature=<signature>

    POST (431 error)
    http://host/client/api?apikey=<api-key>&command=createAccount&response=json&signature=<signature>

    with payload
    { email: 'userthree@mail.com', firstname: 'User', lastname: 'Three', username: 'userthree', password: 'password', roleid: '902f63f7-3235-11f0-8e75-2a84a8b381fa', domainid: '60afa7af-3235-11f0-8e75-2a84a8b381fa' }

  5. weizhouapache commented on Jul 4, 2025

    @weizhouapache
    Member

    GET (401 error) http://host/client/api?apikey=<api-key>&command=createAccount&domainid=<domain-id>&email=userthree%40mail.com&firstname=User&lastname=Three&password=password&response=json&roleid=<role-id>&username=userthree&signature=<signature>

    POST (431 error) http://host/client/api?apikey=<api-key>&command=createAccount&response=json&signature=<signature>

    with payload { email: 'userthree@mail.com', firstname: 'User', lastname: 'Three', username: 'userthree', password: 'password', roleid: '902f63f7-3235-11f0-8e75-2a84a8b381fa', domainid: '60afa7af-3235-11f0-8e75-2a84a8b381fa' }

    sessionkey is needed i think

  6. locked and limited conversation to collaborators on Jul 5, 2025
  7. converted this issue into a discussion #11146 on Jul 5, 2025
  8. added this to the unplanned milestone on Sep 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions