Open unexpand opened 5 years ago
Looks like the same problem i had months ago: https://github.com/RocketChat/Rocket.Chat.js.SDK/pull/79
I have the same issue, using hubot-rocketchat
which is just a "bridge" to the SDK
Code
const addedUser = await robot.adapter.api.post('users.create', { email, name, password, username });
console.log(addedUser);
Logs
ERROR [API] POST error (users.create): { success: false,
error: 'Adding user is not allowed [error-action-not-allowed]',
errorType: 'error-action-not-allowed',
details: { method: 'insertOrUpdateUser', action: 'Adding_user' } }
undefined
I didn't added the permission to my bot, so it's normal that I get success = false
, but I can't handle the error as I get and undefined
object
Did you solve it?
Has anyone been able to solve this issue.
When using SDKs API, I make a post request. Tried async / await as well but no way can I get a handle error returned by request.
api .post("users.create", { name: data.name, email: data.email, password: data.password, username: data.username, roles: ["anonymous"] }) .then(res => console.log(res)) .catch(error => console.error(error));
I get the following error on logs generated by API but no way can I get a handle on error thrown, all I get is undefined.
[API] POST error (users.create): { success: false, error: 'ajskajs is already in use :( [error-field-unavailable]', errorType: 'error-field-unavailable' }