space-physics / pyzenodo3

Simple, clean pure Python 3 Zenodo API (upload, download).
Apache License 2.0
36 stars 5 forks source link

Meta info upload doesn't work #4

Open kasbah opened 4 years ago

kasbah commented 4 years ago

Seems like it's currently commented out in upload.py and un commenting it causes errors.

scivision commented 4 years ago

Yes I agree, I never actually got this working--not a permanent issue, I just didn't take the time to do it.

kikislater commented 1 year ago

Because some values are mandatory to publish metadata such as :

https://developers.zenodo.org/#representation

kikislater commented 1 year ago

I got it working with for example:

data = {
     'metadata': {
        'title': df.iloc[i]["Title"].split(':')[1]+"_test",
        'upload_type': 'dataset',
        'description': df.iloc[i]["Description"],
        'creators': [{'name': 'Sylvain POULAIN',
                       'affiliation': 'IRD',
                       "orcid": "0009-0005-9789-9095"},
                     {'name': 'Julien BARDE',
                       'affiliation': 'IRD'}],
        "keywords": [
             "FAIR data",
             "Design of Experiment",
             "interoperability"],
        "communities":[{'identifier':'uav'},
                       {'identifier':'ecfunded'}],
        "language": "eng",
        "license": {
                "id": "CC-BY-4.0"
                    },
        "publication_date": df.iloc[i]['Date'].split("_\n")[0].split(':')[1],
        "grants": [{"links":{"self":"https://zenodo.org/api/grants/10.13039/501100000780::654241"},"acronym": "PhenoMenAl",
        "program": "H2020",
        "funder": {
          "doi": "10.13039/501100000780",
          "acronyms": [
            "EC"
          ],
          "name": "European Commission",
          "links": {
            "self": "https://zenodo.org/api/funders/10.13039/501100000780"
          }
        }
                     }]
     }
 }
r = requests.put('https://sandbox.zenodo.org/api/deposit/depositions/{}'.format(recid),
                 params={'access_token': ACCESS_TOKEN}, 
                 data=json.dumps(data), 
                 headers=headers)