Pergunta

I've tried adding users using:

curl -X PUT -u myUsername:myPassword http://kaydee.iriscouch.com/_users/org.couchdb.user:myNewUsername -d '{"name":"myNewUsername", "password":"myNewUserPassword", "roles":["reporter", "reader"], "type":"user"}' -H "Content-Type: application/json"

The response was:

{"error":"bad_request","reason":"invalid_json"}
curl: (6) Could not resolve host: password
curl: (3) [globbing] error: bad range specification after pos 8
curl: (3) [globbing] unmatched close brace/bracket at pos 7
curl: (3) [globbing] unmatched close brace/bracket at pos 10

I'm using Windows 8. Is there any changes I need to make to the command?

And I believe IrisCouch is using CouchDB 1.2.

Foi útil?

Solução

So, I found the answer. You need to replace the single-quote (') with double-quote (") and then escape the double-quote inside the JSON string (\"). I think this should be mentioned in the Acralyzer documentation so that Windows user don't need to go the extra step to find the solution.

curl -X PUT -u myUsername:myPassword http://kaydee.iriscouch.com/_users/org.couchdb.user:myNewUsername -d "{\"name\":\"myNewUsername\", \"password\":\"myNewUserPassword\", \"roles\":[\"reporter\", \"reader\"], \"type\":\"user\"}" -H "Content-Type: application/json"

Outras dicas

I fixed this by removing the blank spaces in the json and it worked. Maybe the blank space does not work in the argument when using the ‘curl’ command. If you still want to retain the blank spaces, I suggest you use the solution from your own answer, else try removing the blanks.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top