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 for create_chart requests without folder_id paramter defined #64

Merged
merged 2 commits into from
Jun 24, 2021
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: 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