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

Fix handling of empty metadata when uploading data files #207

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pyDataverse/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1847,9 +1847,10 @@ def upload_datafile(self, identifier, filename, json_str=None, is_pid=True):
url += "/datasets/{0}/add".format(identifier)

files = {"file": open(filename, "rb")}
return self.post_request(
url, data={"jsonData": json_str}, files=files, auth=True
)
metadata = {}
if json_str is not None:
metadata["jsonData"] = json_str
return self.post_request(url, data=metadata, files=files, auth=True)

def update_datafile_metadata(self, identifier, json_str=None, is_filepid=False):
"""Update datafile metadata.
Expand Down