Unfortunately I get the following error while trying to add a user via CLI:
$ drone user add octocat
json: cannot unmarshal array into Go value of type drone.User
Unfortunately I get the following error while trying to add a user via CLI:
$ drone user add octocat
json: cannot unmarshal array into Go value of type drone.User
I do not get an error when trying to add a user.
$ drone user add foobarbaz
Successfully added user foobarbaz
Can you confirm the following:
The most common root causes for this error messages I see are when someone has a reverse proxy in front of drone and the CLI requests are not reaching the server. Usually this happens when auto-redirect to https is configured, and the CLI is not being provided the https address.
Thats funny because $ drone info
and $ drone user ls
worked but not adding new user.
Indeed it was http(s) error. With https in the URL it worked. Thank you :)!
The technical reason for this is because the Go HTTP client will not automatically follow redirects when the HTTP request has a body. The body is an io.Reader (stream) and can only be consumed once, thus preventing retries. Creating a user is a POST and has a body. The info and ls CLI commands are GET requests which do not have a body, and can be automatically redirected.