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

Problems with edit.metadata with Pydataverse #151

Open
TutasiCSUC opened this issue Oct 26, 2022 · 1 comment
Open

Problems with edit.metadata with Pydataverse #151

TutasiCSUC opened this issue Oct 26, 2022 · 1 comment

Comments

@TutasiCSUC
Copy link

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants