From 04a2ee09cff2eb2b6c4788c72ab7d734ba78e1af Mon Sep 17 00:00:00 2001 From: Martin Diaz Date: Wed, 9 Sep 2020 15:26:05 -0300 Subject: [PATCH] :hammer: Resolved some issues --- meli/rest.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/meli/rest.py b/meli/rest.py index bf3ae05..5db6ae3 100644 --- a/meli/rest.py +++ b/meli/rest.py @@ -151,11 +151,24 @@ def request(self, method, url, query_params=None, headers=None, if 'Content-Type' not in headers: headers['Content-Type'] = 'application/json' + encode_url = url + url=url.replace('%3F','?') + url=url.replace('%3D','=') + url=url.replace('%26','&') + url=url.replace('%7B','{') + url=url.replace('%7D','}') + url=url.replace('%2C',',') + already_querys = (encode_url == url) + url=url.replace('%2F','/') + try: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: if query_params: - url += '?' + urlencode(query_params) + if already_querys: + url += '?' + urlencode(query_params) + else: + url += '&' + urlencode(query_params) if re.search('json', headers['Content-Type'], re.IGNORECASE): request_body = None if body is not None: @@ -205,8 +218,11 @@ def request(self, method, url, query_params=None, headers=None, raise ApiException(status=0, reason=msg) # For `GET`, `HEAD` else: + if already_querys: + url += '?' + urlencode(query_params) + else: + url += '&' + urlencode(query_params) r = self.pool_manager.request(method, url, - fields=query_params, preload_content=_preload_content, timeout=timeout, headers=headers)