Skip to content
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 #112

Open
veustp opened this issue Feb 18, 2021 · 4 comments
Open

Delete Roles via API not working #112

veustp opened this issue Feb 18, 2021 · 4 comments
Assignees
Labels
pkg:api api related activities prio:high status:wip Work in progress type:bug Something isn't working

Comments

@veustp
Copy link

veustp commented Feb 18, 2021

using
Windows 64bit
pydataverse 0.3.0
python 3.7.9
dataverse v. 4.20 build 413-4e07b62

Using NativeApi calls

apiProd = NativeApi(baseUrlProd, apiKeyProd)

To Get A Role:

resp = apiProd.get_request(baseUrlProd+"/api/roles/10")
{'status': 'OK', 'data': {'alias': 'rev', 'name': 'reviewer', 'permissions': [], 'description': 'ReviewerRole', 'id': 11, 'ownerId': 1}}

The role is found - no problem here.

To Delete A Role:

resp = apiProd.delete_request(baseUrlProd+"/api/roles/10")
{'status': 'ERROR', 'message': 'Command edu.harvard.iq.dataverse.engine.command.impl.DeleteRoleCommand@721061c3 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.'}

Deleting the role does not work.

Using the standard requests module:

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)

@veustp veustp added status:incoming Newly created issue to be forwarded type:bug Something isn't working labels Feb 18, 2021
@skasberger skasberger self-assigned this Feb 24, 2021
@skasberger skasberger added pkg:api api related activities status:confirmed Is a valid issue and will be moved forward soon. and removed status:incoming Newly created issue to be forwarded labels Feb 24, 2021
@skasberger skasberger added this to the v0.4.0 milestone Feb 24, 2021
@skasberger
Copy link
Member

Thanks for the issue!

This looks like an issue more on the Dataverse side, than from pyDataverse. Have not tested the role functionalities myself, but as you used the basic request functions, they should work as expected.

@pdurbin @djbrooke Can you say more about the Java Exception raised and returned as Error message?

@djbrooke
Copy link
Member

Hi @veustp - can you open an issue for this in main issue tracker so that we can take a look?

https://github.com/IQSS/dataverse/issues

@pdurbin
Copy link
Member

pdurbin commented Feb 24, 2021

See IQSS/dataverse#7633 (thanks for opening it, @veustp).

@skasberger skasberger added status:wip Work in progress and removed status:confirmed Is a valid issue and will be moved forward soon. labels Feb 24, 2021
@skasberger skasberger mentioned this issue Mar 14, 2021
35 tasks
@pdurbin
Copy link
Member

pdurbin commented Feb 14, 2024

As discussed during the 2024-02-14 meeting of the pyDataverse working group, we are closing old milestones in favor of a new project board at https://github.com/orgs/gdcc/projects/1 and removing issues (like this one) from those old milestones. Please feel free to join the working group! You can find us at https://py.gdcc.io and https://dataverse.zulipchat.com/#narrow/stream/377090-python

@pdurbin pdurbin removed this from the v0.4.0 milestone Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:api api related activities prio:high status:wip Work in progress type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants