Error 400 still occurring on some configurations
hellricer opened this issue · 4 comments
There are apparently still issues with error 400 on post requests since #18. Seems to happen only on some setups for some reason - might be related to different versions of dependencies?
Python 3.8.3 & 3.9.1
requests 2.25.1
oauthlib 3.1.0
Test code:
import discogs_client
ds = discogs_client.Client('DevApp/1.0', user_token='...')
me = ds.identity()
me.wantlist.add(89411)
Okay, I think I found the issue. When using the user_token it uses UserTokenRequestsFetcher
, which does not convert the data to json string.
discogs_client/discogs_client/fetchers.py
Lines 55 to 63 in 9d1292a
I changed the fetch method to match the oauth one like so
def fetch(self, client, method, url, data=None, headers=None, json_format=True):
data = json.dumps(data) if json_format and data else data
resp = requests.request(method, url, params={'token':self.user_token},
data=data, headers=headers)
...
Hope this is the only culprit
Maybe this method should be implemented in the base Nvm each class implements it differently 🤦Fetcher
class?
Good solution to this could be implementing the method properly in RequestsFetcher
class and inheriting it in OAuth2Fetcher
and UserTokenRequestsFetcher
(I know, annoying mismatched naming, lol)
Arghh, thinking too fast without inspecting the code properly
Great find, thanks. Would you mind creating the PR, or do you want to include it in #27?
I'll create a new PR, as it's not really related to changes made in #27
@AnssiAhola @hellricer PR was merged and package with change has been released - version 2.3.8. I'm going to close this issue but feel free to open it again if the problem arises. Thanks for the quick work guys.