-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete Roles via API not working #7633
Comments
@veustp thanks for the bug report. Do you have access to server.log? That's where the details will be of why the command was rolled back. (Maybe the role is still in use?) Perhaps you can attach it here (you'll have to rename it to server.log.txt) or email it to support@dataverse.org. Also, I checked out API test suite and we have examples of deleting role assignments but not roles themselves (from a quick look anyway). So, the definition of done for this issue should include adding some tests. |
I did some more tests and have added the server.log file as requested. #GETTING THE ROLES --> output: The roles we created ourselves have an ownerId - which distinguishes them from the other (default) roles (e.g. Member below): #TRYING TO DELETE THE ROLES THAT HAD BEEN CREATED --> output: br, |
@veustp thanks. I'm not sure what's going on but the problem is happening for me too on 5.3. For anyone who picks this up, pay attention to this line: In addition, the docs should be improved in the API Guide for create, show, and delete role. |
FWIW: Looking at the code with
|
@qqmyers yeah, you're right. It should probably be |
Expanded the scope a bit after consulting with Danny and Gustavo.
|
using
dataverse v. 4.20 build 413-4e07b62
Using the standard requests module from within a python environment (python 3.7.9):
import requests
headers = {'X-Dataverse-key':apiKeyProd,
'Content-Type':'application/json'}
r = requests.get(baseUrlProd+'/api/roles/11', headers=headers)
Getting the role works
b'{"status":"OK","data":{"alias":"rev","name":"reviewer","permissions":[],"description":"ReviewerRole","id":11,"ownerId":1}}'
Deleting the role:
r = requests.delete(baseUrlProd+'/api/roles/11', headers=headers)
b'{"status":"ERROR","message":"Command edu.harvard.iq.dataverse.engine.command.impl.DeleteRoleCommand@7bd352e6 failed: Exception thrown from bean: javax.ejb.EJBTransactionRolledbackException: Exception thrown from bean: java.lang.IllegalArgumentException: You have attempted to set a value of type class java.lang.Long for parameter roleId with expected type of class edu.harvard.iq.dataverse.authorization.DataverseRole from query string SELECT r FROM RoleAssignment r WHERE r.role=:roleId."}'
Does not work either.
Additional remark:
It was already quite difficult to get the role ID right - I expected it to be the "alias" but it needed to be the id which is nowhere displayed in the dataverse interface. It was not clear from the documentation what the ID should be that needed to be used for the API (https://guides.dataverse.org/en/latest/api/native-api.html#explicit-groups - see the Roles section)
Additional remark II: I mistakingly posted this earlier on the pydataverse repository and was requested by Danny Brooke to re-raise the issue here.
The text was updated successfully, but these errors were encountered: