pyDataverse icon indicating copy to clipboard operation
pyDataverse copied to clipboard

Problems with edit.metadata with Pydataverse

Open TutasiCSUC opened this issue 3 years ago • 1 comments

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

TutasiCSUC avatar Oct 26 '22 08:10 TutasiCSUC

You have to import the JSON first into pyDataverse. https://pydataverse.readthedocs.io/en/latest/user/basic-usage.html#create-dataset

skasberger avatar Nov 02 '22 14:11 skasberger