From fc4acb89d6ca81193a874820cceff1b838038136 Mon Sep 17 00:00:00 2001 From: Harmon Date: Fri, 19 Feb 2021 10:26:16 -0600 Subject: [PATCH] Only include media_category when specified in API.chunked_upload_init Also improve quotation mark type consistency --- tweepy/api.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tweepy/api.py b/tweepy/api.py index a4dcf5d..1ec8b42 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -418,14 +418,17 @@ class API: """ :reference https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload-init """ headers = {'Content-Type': 'application/x-www-form-urlencoded'} + post_data = { 'command': 'INIT', 'total_bytes': total_bytes, 'media_type': media_type, - 'media_category': media_category } + if media_category is not None: + post_data['media_category'] = media_category if additional_owners is not None: - post_data["additional_owners"] = list_to_csv(additional_owners) + post_data['additional_owners'] = list_to_csv(additional_owners) + return self.request( 'POST', 'media/upload', *args, headers=headers, post_data=post_data, upload_api=True, **kwargs -- 2.25.1