Stream: troubleshooting

Topic: โœ” MyData API


view this post on Zulip Mohsen Jafari (Apr 24 2024 at 09:37):

Using the following API I could fetch dataverses:

export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export SERVER_URL=https://demo.dataverse.org
export ROLE_IDS=6
export DVOBJECT_TYPES=Dataverse
export PUBLISHED_STATES=Unpublished
export PER_PAGE=10

curl -H "X-Dataverse-key:$API_TOKEN" "$SERVER_URL/api/mydata/retrieve?role_ids=$ROLE_IDS&dvobject_types=$DVOBJECT_TYPES&published_states=$PUBLISHED_STATES&per_page=$PER_PAGE"

However, I am curious if it is possible to say to this API that I need only those dataverses that the user is the Admin or Member of.

Also, Is it possible to say those dataverses that are Published or Unpublished or Draft?

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 24 2024 at 11:02):

Hmm, I'm looking at https://guides.dataverse.org/en/6.2/api/native-api.html#mydata

What if you pass ROLE_IDS=1 for Admin?

view this post on Zulip Mohsen Jafari (Apr 24 2024 at 11:05):

Philip Durbin said:

Hmm, I'm looking at https://guides.dataverse.org/en/6.2/api/native-api.html#mydata

What if you pass ROLE_IDS=1 for Admin?

That works, but I need to define more than just one role_id.

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 24 2024 at 11:25):

Hmm :thinking:

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 24 2024 at 11:28):

I looks like the API accepts a list: @QueryParam("role_ids") List<Long> roleIds

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 24 2024 at 11:31):

In a Java test we do this: ArrayList<Long> emptyRoleIdsList = new ArrayList<>();

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 24 2024 at 11:31):

I'm not sure how to do it with curl. Maybe try comma-separated?

view this post on Zulip Mohsen Jafari (Apr 25 2024 at 06:27):

Philip Durbin said:

I'm not sure how to do it with curl. Maybe try comma-separated?

I will check and let you know.

view this post on Zulip Mohsen Jafari (Apr 25 2024 at 14:46):

Mohsen Jafari said:

Philip Durbin said:

I'm not sure how to do it with curl. Maybe try comma-separated?

I will check and let you know.

Could you share the line of code in GitHub for this endpoint, please?

view this post on Zulip Sherry Lake (Apr 25 2024 at 15:36):

@Mohsen Jafari I think this is what you are asking for:
https://github.com/IQSS/dataverse/blob/2f6d3aafaf75cf7b23ae4a9fd7865fbe681841ae/src/main/java/edu/harvard/iq/dataverse/mydata/DataRetrieverAPI.java

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 25 2024 at 15:39):

Yes, thank you. This line is the entry point: https://github.com/IQSS/dataverse/blob/v6.2/src/main/java/edu/harvard/iq/dataverse/mydata/DataRetrieverAPI.java#L271

view this post on Zulip Sherry Lake (Apr 25 2024 at 16:16):

Thanks, @Philip Durbin I guess the link I have is the currently being worked on branch? You sent the branch for the current release 6.2? Still trying to understand github.......

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 25 2024 at 17:52):

@Sherry Lake ha. There's nothing wrong with your link. I just prefer putting version numbers (e.g. v6.2) in the URL when I can so it's clear which version we're talking about.

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 25 2024 at 17:53):

When you do a search on GitHub the results are always commits rather than versions. I'm not sure why.

view this post on Zulip Johannes D (Apr 26 2024 at 06:22):

I have those requests in my local history... http://localhost:8080/api/mydata/retrieve?dvobject_types=Dataset&role_ids=6&role_ids=34&published_states=In+Review&published_states=Published&published_states=Unpublished&published_states=Draft&selected_page=1

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 26 2024 at 09:04):

Oh! Duplicate them! Thanks!

view this post on Zulip Notification Bot (Apr 26 2024 at 09:24):

Mohsen Jafari has marked this topic as resolved.

view this post on Zulip Notification Bot (Apr 26 2024 at 09:24):

Mohsen Jafari has marked this topic as unresolved.

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 26 2024 at 09:33):

Should we add a note to the docs? Does anyone want to create an issue?

view this post on Zulip Mohsen Jafari (Apr 26 2024 at 09:46):

I think this way of sending params to the endpoint should be added to the existing documentation, so other people also know about it.

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 26 2024 at 09:57):

Right. Me too. Do you mind creating an issue?

view this post on Zulip Notification Bot (Apr 26 2024 at 10:02):

Mohsen Jafari has marked this topic as resolved.

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 26 2024 at 10:31):

Thanks for creating this issue! Add more information to the documentation about how api/mydata/retrieve is called #10530


Last updated: Oct 30 2025 at 06:21 UTC