"405 METHOD NOT ALLOWED" when trying to submit listens via python

I’ve downloaded my listening history from libre.fm into a csv file, and I’m now trying to submit it to listenbrainz. When I try the example code for the submit-listens endpoint from https://listenbrainz.readthedocs.io/en/latest/dev/api-usage.html, I get this error:

requests.exceptions.HTTPError: 405 Client Error: METHOD NOT ALLOWED for url: https://api.listenbrainz.org/1/submit-listens

The only change I’ve made to the code is to set the ROOT url to “api.listenbrainz.org”.

Has anyone else encountered this?

It looks like listenbrainz is redirecting http requests to https, which is then causing the request to be sent with a GET instead of a POST.
I tested that changing this line:




causes the submission to correctly work. I’ll open a ticket to suggest that we use HTTP 308 instead of 301 in order to preserve the method when performing a redirect. We’ll also update the documentation to submit directly to https. Thanks for reporting the issue!