RESPONSE [500]

68 views
Skip to first unread message

Tutasi

unread,
Jul 15, 2022, 3:22:29 AM7/15/22
to Dataverse Users Community
Hi, I am learning how to use API and Pydataverse. I want to update metadata of an unpublished dataset in a demo Dataverse of my organisation from a file or a json writen by code. However, I can't modify de metadata , I get 'Response[500] and the metadata isn't updated. My code is: 

from pyDataverse.api import NativeApi, DataAccessApi
from pyDataverse.models import Dataverse

base_url = *****
token=*****
api = NativeApi(base_url,token)
data_api = DataAccessApi(base_url,token)
doi =****
new_metadata=****
resp = api.edit_dataset_metadata(doi,new_metadata)

When I run, I get Response[500] and when I run resp.json(), I get {}

Philip Durbin

unread,
Jul 15, 2022, 11:37:04 AM7/15/22
to dataverse...@googlegroups.com
Hi Tutasi,

The Dataverse API shouldn't return 500 errors so it's likely you've found a bug.

However, I don't know how to reproduce it without more information.

Can you please provide the JSON file you're using? Also, what version of Dataverse are you using? And what version of pyDataverse?

The pyDataverse docs link to a JSON file, but the link is broken, unfortunately. I just tried to fix this in https://github.com/gdcc/pyDataverse/pull/148 . Here's a direct link to a JSON file you can try: https://guides.dataverse.org/en/5.11/_downloads/cb0fae993277527ea354dc15bc5db864/dataset-edit-metadata-sample.json

If you have success with that JSON file, perhaps you can get it working with your own data. Good luck!

Thanks,

Phil

--
You received this message because you are subscribed to the Google Groups "Dataverse Users Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dataverse-commu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dataverse-community/f3ee3e12-f8ec-4873-ae17-ce6480a87014n%40googlegroups.com.


--

Tutasi

unread,
Jul 19, 2022, 5:27:45 AM7/19/22
to Dataverse Users Community
Hi,  for example I have a dataset with 3 files and I want to change the description one of them using Pydataverse.  The metadata of the dataset is  :

{'status': 'OK', 'data': {'id': 10385, 'identifier': 'data190', 'persistentUrl': 'https://doi.org/10.80051/data190', 'protocol': 'doi', 'authority': '10.80051', 'publisher': 'Repositori de Dades de Recerca', 'publicationDate': '2022-07-15', 'storageIdentifier': 'file://10.80051/data190', 'latestVersion': {'id': 640, 'datasetId': 10385, 'datasetPersistentId': 'doi:10.80051/data190', 'storageIdentifier': 'file://10.80051/data190', 'versionNumber': 1, 'versionMinorNumber': 0, 'versionState': 'RELEASED', 'lastUpdateTime': '2022-07-15T10:13:05Z', 'releaseTime': '2022-07-15T10:13:05Z', 'createTime': '2022-07-14T07:18:24Z', 'license': 'NONE', 'fileAccessRequest': False, 'metadataBlocks': {'citation': {'displayName': 'Citation Metadata', 'fields': [{'typeName': 'title', 'multiple': False, 'typeClass': 'primitive', 'value': 'prueba dataset'}, {'typeName': 'author', 'multiple': True, 'typeClass': 'compound', 'value': [{'authorName': {'typeName': 'authorName', 'multiple': False, 'typeClass': 'primitive', 'value': 'LastAuthor1, FirstAuthor1'}, 'authorAffiliation': {'typeName': 'authorAffiliation', 'multiple': False, 'typeClass': 'primitive', 'value': 'AuthorAffiliation1'}}]}, {'typeName': 'datasetContact', 'multiple': True, 'typeClass': 'compound', 'value': [{'datasetContactName': {'typeName': 'datasetContactName', 'multiple': False, 'typeClass': 'primitive', 'value': 'LastContact1, FirstContact1'}, 'datasetContactEmail': {'typeName': 'datasetContactEmail', 'multiple': False, 'typeClass': 'primitive', 'value': 'Contac...@mailinator.com'}}]}, {'typeName': 'dsDescription', 'multiple': True, 'typeClass': 'compound', 'value': [{'dsDescriptionValue': {'typeName': 'dsDescriptionValue', 'multiple': False, 'typeClass': 'primitive', 'value': 'DescriptionText'}}]}, {'typeName': 'subject', 'multiple': True, 'typeClass': 'controlledVocabulary', 'value': ['Medicine, Health and Life Sciences']}, {'typeName': 'kindOfData', 'multiple': True, 'typeClass': 'primitive', 'value': ['N/A']}]}}, 'files': [{'description': 'prueba', 'label': 'datafile-1.txt', 'restricted': False, 'version': 1, 'datasetVersionId': 640, 'dataFile': {'id': 10387, 'persistentId': '', 'pidURL': '', 'filename': 'datafile-1.txt', 'contentType': 'text/plain', 'filesize': 6, 'description': 'prueba', 'storageIdentifier': 'file://181fbcaaf30-cf9397a073ed', 'rootDataFileId': -1, 'md5': '5a8dd3ad0756a93ded72b823b19dd877', 'checksum': {'type': 'MD5', 'value': '5a8dd3ad0756a93ded72b823b19dd877'}, 'creationDate': '2022-07-14'}}, {'description': '', 'label': 'datafile-2.txt', 'restricted': False, 'version': 1, 'datasetVersionId': 640, 'dataFile': {'id': 10388, 'persistentId': '', 'pidURL': '', 'filename': 'datafile-2.txt', 'contentType': 'text/plain', 'filesize': 6, 'description': '', 'storageIdentifier': 'file://181fbce140e-eb54185bbad8', 'rootDataFileId': -1, 'md5': '5a8dd3ad0756a93ded72b823b19dd877', 'checksum': {'type': 'MD5', 'value': '5a8dd3ad0756a93ded72b823b19dd877'}, 'creationDate': '2022-07-14'}}, {'description': 'prueba', 'label': 'datafile.txt', 'restricted': False, 'version': 1, 'datasetVersionId': 640, 'dataFile': {'id': 10386, 'persistentId': '', 'pidURL': '', 'filename': 'datafile.txt', 'contentType': 'text/plain', 'filesize': 6, 'description': 'prueba', 'storageIdentifier': 'file://181fb96182e-3daabf83c693', 'rootDataFileId': -1, 'md5': '5a8dd3ad0756a93ded72b823b19dd877', 'checksum': {'type': 'MD5', 'value': '5a8dd3ad0756a93ded72b823b19dd877'}, 'creationDate': '2022-07-14'}}]}}}

How could I do this change using pyDataverse?

My version of PyDataverse is :

Name: pyDataverse Version: 0.3.1 Summary: A Python module for the Dataverse API's and its data-types Home-page: https://github.com/gdcc/pyDataverse Author: Stefan Kasberger Author-email: stefan.k...@univie.ac.at License: MIT Location: c:\users\juan.tutasi\anaconda3\lib\site-packages Requires: jsonschema, requests Required-by: Note: you may need to restart the kernel to use updated packages.

I don't know the version of the dataverse. Our Dataverse page is https://dataverse.csuc.cat/ , but I'm working on a demoversion


El dia divendres, 15 de juliol de 2022 a les 17:37:04 UTC+2, Philip Durbin va escriure:

Stefan Kasberger

unread,
Jul 20, 2022, 4:43:29 AM7/20/22
to Dataverse Users Community
Hi Tutasi,

please open an issue on the pyDataverse GitHub page [1]. I will then try to reproduce the problem. As far as I know right now, the edit/update dataset functionality is a bit tricky, but have to check this out, if pyDataverse can help to make it easier.


Cheerz, Stefan
Reply all
Reply to author
Forward
0 new messages