Skip to content

Commit

Permalink
Merge pull request #64 from elanals/fix/folder_id-bug
Browse files Browse the repository at this point in the history
Fix for create_chart requests without folder_id paramter defined
  • Loading branch information
chekos authored Jun 24, 2021
2 parents 43521ac + f0c86d0 commit 6181069
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions datawrapper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ def create_chart(
_header = self._auth_header
_header["content-type"] = "application/json"

_data = {"title": title, "type": chart_type, "folderId": folder_id}
_data = {"title": title, "type": chart_type}

if folder_id:
_data["folderId"] = folder_id

new_chart_response = r.post(
url=self._CHARTS_URL, headers=_header, data=json.dumps(_data)
Expand All @@ -174,7 +177,7 @@ def create_chart(
print(f"New chart {chart_info['type']} created!")
else:
print(
"Chart could not be created, check your authorization credentials (access token)"
f"Chart could not be created, check your authorization credentials (access token){', and that the folder_id is valid (i.e exists, and your account has access to it)' if folder_id else ''}"
)

if data is not None:
Expand Down

0 comments on commit 6181069

Please sign in to comment.