Problems with edit.metadata with Pydataverse
Opened this issue · 1 comments
TutasiCSUC commented
Hi, I'im trying to edit metadata of an existing dataset, for example its title. 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= " "
dataset = api.get_dataset(DOI)
dictmetadata=dataset.json()
dictmetadata['data']['latestVersion']['metadataBlocks']['citation']['fields'][0]['value']='new title'
import json
jsonStr = json.dumps(dictmetadata)
api.edit_dataset_metadata(DOI, jsonStr,is_pid=True, replace=True, auth=True)
I get as response [500] and the title isn't changed. How could i fix it? And how would it be with a Json file. Thanks
skasberger commented
You have to import the JSON first into pyDataverse.
https://pydataverse.readthedocs.io/en/latest/user/basic-usage.html#create-dataset