From e00782aeb7277b2333831c215792c2392162b02c Mon Sep 17 00:00:00 2001 From: Jan Krcmar Date: Fri, 3 May 2024 14:39:58 +0200 Subject: [PATCH] Fix query string encoding according to the odata-v4.01-part2-url-conventions, part 2.1 URL Parsing Percent-decode path segments, query option names, and query option values exactly once Background: requests library uses "+" sign instead of "%20" which collides with odata specification. Instead of using quote_via=quote_plus, odata library has to use the quote_via=quote function to match the odata specification --- odata/connection.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/odata/connection.py b/odata/connection.py index 2fa54b3..33259e1 100644 --- a/odata/connection.py +++ b/odata/connection.py @@ -6,6 +6,7 @@ import requests from requests.exceptions import RequestException +from urllib.parse import urlencode, quote from odata import version from .exceptions import ODataError, ODataConnectionError @@ -40,6 +41,8 @@ def __init__(self, session=None, auth=None): def _apply_options(self, kwargs): kwargs['timeout'] = self.timeout + if "params" in kwargs and kwargs["params"]: + kwargs["params"] = urlencode(kwargs["params"], quote_via=quote) if self.auth is not None: kwargs['auth'] = self.auth