Reputation: 3515
I'm trying to add a few users and also set their permissions with a provided JSON, but it's not working. This command is working fine, but i want to add multiple users with JSON:
curl -u admin:admin -H "Accept: application/json" -H "Content-Type: application/json" -X PUT "http://stash.mydomain.com/rest/api/1.0/projects/CPC/permissions/users?name=myuser&permission=PROJECT_WRITE"
This command not working :
curl -u admin:admin -H "Accept: application/json" -H "Content-Type: application/json" -X PUT "http://stash.mydomain.com/rest/api/1.0/projects/CPC/permissions/users" -d '{"name" : "myuser", "permission" : "PROJECT_READ"}'
I'm getting an error: {"errors":[{"context":null,"message":"Permission must be specified.","exceptionName":null}]}
Any idea how to solve it? I need to add multiple users at once, this could be done using an Array inside a JSON.
Upvotes: 0
Views: 2231
Reputation: 71
You can add muliple users by inserting the name paramter multiple times like
curl -u admin:admin -X PUT "http://stash.mydomain.com/rest/api/1.0/projects/CPC/permissions/users?name=myuser&name=myuser2&permission=PROJECT_WRITE"
The quotes around the URL are important. Without, you will get the error message again. See how to PUT multiple query parameter in REST web service
Upvotes: 5