Commit fb53d8cd authored by Enrique Garcia's avatar Enrique Garcia
Browse files

Merge branch 'correct_get_methods' into 'master'

Correct get methods

See merge request !20
parents d3f575a0 54e5f0e0
Pipeline #120617 passed with stages
in 1 minute and 29 seconds
......@@ -91,9 +91,9 @@ class ZenodoAPI:
:return: request.get method
"""
# In case of entries created by oneself, and maybe not published yet, the method to fetch them is
# request.get('api/deposit/deposition/{entry_id}')
# To fetch any other entry not belonging/published to yourself/user
# In case of entries created by oneself, usually in the process of being created, the method to fetch
# a record is request.get('api/deposit/deposition/{entry_id}'), see the upload_file_entry methods
# To fetch any other entry, already published, use
url = f"{self.zenodo_api_url}/records/{entry_id}"
return requests.get(url, params=self.parameters)
......@@ -114,11 +114,12 @@ class ZenodoAPI:
:return: request.put method
"""
# 1 - Retrieve and recover information of an existing deposit
fetch = self.fetch_entry(str(entry_id))
# 1 - Retrieve and recover information of a record that is in process of being published
fetch = requests.get(f"{self.zenodo_api_url}/deposit/depositions/{entry_id}",
params=self.parameters)
# 2 - Upload the files
bucket_url = fetch.json()['links']['bucket'] # full url is recovered from fetch (GET) method
bucket_url = fetch.json()['links']['bucket'] # full url is recovered from previous GET method
url = f"{bucket_url}/{name_file}"
with open(path_file, 'rb') as upload_file:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment