Skip to content

"you must be logged in to do this" while creating a user with REST API #10792

@huiminzeng

Description

@huiminzeng

Description:

Hello everyone! I was trying to create a user with REST API, but i always got the error: you must be logged in to do this. I read some related issues, but they are not so useful for me. I will appreciate it, if you have any idea. Thank you very much!

Server Setup Information:

  • Version of Rocket.Chat Server: 0.64.1
  • Operating System: Ubuntu 16.04
  • Deployment Method(snap/docker/tar/etc): docker
  • Number of Running Instances: 1
  • Node Version: v8.11.1
  • mongoDB Version: 3.2

Steps to Reproduce:

1. create an admin (on the Web Interface):

username=huimin
password=12

2. Login with REST API

curl http://localhost:3000/api/v1/login
-d "username=huimin&password=123"

3. Create a new user with REST API (The Token and UserId are available after STEP2)

curl -H "X-Auth-Token: f3N9AOig5FKgr_L4Gnrc_QE_yheUk6lyRKaV2eRlxFp"
-H "X-User-Id: 7HZbmGjYLkkSW7nFC"
-H "Content-type:application/json"
http://localhost:3000/api/v1/users.create
-d '{"name": "A", "email": "[email protected]", "password": "123", "username":"A" }'

Expected behavior:

A new user A could be created successfully

Actual behavior:

{"status":"error","message":"You must be logged in to do this."}

Thanks for any idea!

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions