diff --git a/src/twython/api.py b/src/twython/api.py index 2ed50bc2..fab4a4e8 100644 --- a/src/twython/api.py +++ b/src/twython/api.py @@ -140,8 +140,11 @@ class Twython(EndpointsMixin, object): params = params or {} func = getattr(self.client, method) - params, files = _transparent_params(params) - + if type(params) is dict: + params, files = _transparent_params(params) + else: + params = params + files = list() requests_args = {} for k, v in self.client_args.items(): # Maybe this should be set as a class variable and only done once? @@ -199,8 +202,10 @@ class Twython(EndpointsMixin, object): else: content = response.json() except ValueError: - raise TwythonError('Response was not valid JSON. \ - Unable to decode.') + # Send the response as is for working with /media/metadata/create.json. + content = response.content +# raise TwythonError('Response was not valid JSON. \ +# Unable to decode.') return content @@ -253,10 +258,8 @@ class Twython(EndpointsMixin, object): url = endpoint else: url = '%s/%s.json' % (self.api_url % version, endpoint) - content = self._request(url, method=method, params=params, api_call=url) - return content def get(self, endpoint, params=None, version='1.1'): diff --git a/src/twython/endpoints.py b/src/twython/endpoints.py index c91b88a8..47bef239 100644 --- a/src/twython/endpoints.py +++ b/src/twython/endpoints.py @@ -14,6 +14,7 @@ This map is organized the order functions are documented at: https://dev.twitter.com/docs/api/1.1 """ +import json import os import warnings try: @@ -145,7 +146,10 @@ class EndpointsMixin(object): return self.post('https://upload.twitter.com/1.1/media/upload.json', params=params) def set_description(self, **params): - return self.post('media/metadata/create', params=params) + """ Adds a description to an image.""" + # This method only accepts strings, no dictionaries. + params = json.dumps(params) + return self.post("media/metadata/create", params=params) def upload_video(self, media, media_type, size=None): """Uploads video file to Twitter servers in chunks. The file will be available to be attached