Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebUI API: setShareLimits method returns status code 400 #20110

Closed
antonkvm opened this issue Dec 9, 2023 · 4 comments
Closed

WebUI API: setShareLimits method returns status code 400 #20110

antonkvm opened this issue Dec 9, 2023 · 4 comments
Labels
WebAPI WebAPI-related issues/changes

Comments

@antonkvm
Copy link

antonkvm commented Dec 9, 2023

qBittorrent & operating system versions

qBittorrent: v4.6.2 (64-Bit)
Operating System: Raspberry Pi OS / Debian GNU/Linux 11 (bullseye)
Qt: 6.6.1
libtorrent: 2.0.9.0

What is the problem?

Trying to use the setShareLimits API method no longer works and currently returns "400 - Bad Request". I used the same request previously in a python script, which used to work as expected. I can verify that my last successful call to that API method was on November 11th 2023, but I can't pinpoint what version I was using back then, although I do update fairly regularly. I have not changed the way I call that method since.

I have tried out using other API methods, like /torrents/addTags, using the same torrent hash and session cookie, and that still succeeds as expected.

Steps to reproduce

  1. Use the /auth/login method to fetch a session cookie
  2. Use that session cookie to make a POST request to the /torrents/setShareLimits API endpoint (see below for details)
  3. See that the HTTP response is code 400, bad request. Checking the share limits in the WebUI shows that the intended changes were not applied.

Additional context

cURL Snippet generated by Postman:

curl --location 'https://[redacted_host]/api/v2/torrents/setShareLimits' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: SID=[redacted]' \
--data-urlencode 'hashes=[redacted]' \
--data-urlencode 'ratioLimit=13.0' \
--data-urlencode 'seedingTimeLimit=13000.0'
Bildschirmfoto 2023-12-09 um 13 21 36

<< removed irrelevant logs and preferences >>

@thalieht thalieht added the WebAPI WebAPI-related issues/changes label Dec 9, 2023
@PISTOLCUPCAKES
Copy link

I'm seeing the same issue on 4.6.2 using a script that previously worked (not sure which version it worked on). I also tried submitting the request with form data, as that was the fix for a different endpoint, but that didn't work either.
Postman request formatted with form-data:

curl --location --request POST 'http://[redacted]/api/v2/torrents/setShareLimits' --header 'Cookie: SID=[redacted]' --form 'hashes="[redacted]"' --form 'ratioLimit="-1"' --form 'seedingTimeLimit="14400"'

@antonkvm
Copy link
Author

antonkvm commented Dec 26, 2023

I figured out that the last version where this API method still worked was v4.5.5. So the issue must have been caused by something in the v4.6.0 release.

@glassez
Copy link
Member

glassez commented Dec 26, 2023

So the issue must have been caused by something in the v4.6.0 release.

#19294 has added one more parameter to setShareLimits request.

@antonkvm
Copy link
Author

I see, thanks! Adding the inactiveSeedingTimeLimitparameter to the setShareLimits request solved my issue.

Here is my now working API request:

curl --location 'https://[redacted_host]/api/v2/torrents/setShareLimits' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --header 'Cookie: SID=[redacted_session_cookie]' \
  --data-urlencode 'hashes=[redacted_torrent_info_hash]' \
  --data-urlencode 'ratioLimit=10' \
  --data-urlencode 'seedingTimeLimit=-1' \
  --data-urlencode 'inactiveSeedingTimeLimit=-1'

I appreciate your reply, but shouldn't this have been communicated in the release notes and the WebUI API reference? I was pretty stumped until now and was unable to find any resources pointing me to this solution. And in general, would it not be helpful to include a short error message in the API response, something like "Bad Request: missing parameter"?

I'll gladly contribute this info to the wiki myself, once I figure out how that works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebAPI WebAPI-related issues/changes
Projects
None yet
Development

No branches or pull requests

4 participants