scttcper / qbittorrent

qBittorrent api wrapper
https://qbittorrent.vercel.app
MIT License
42 stars 13 forks source link

400 Bad Request #130

Open quinm0 opened 4 weeks ago

quinm0 commented 4 weeks ago

I am using Bun(1.1.8) to run this so maybe that's something. I'm getting an invalid request error when trying to use any non GET request from the library. I like to assume Bun isn't causing this issue, but I'll check that out next

But basically when I run this code

const client = new QBittorrent({
  baseUrl: "http://HOSTNAME:PORT/",
  username: "admin",
  password: "password",
});

const torrents = await client.listTorrents();
await Promise.all(
  torrents.map(async (torrent) => {
    console.log("Pausing", torrent.name, torrent.hash);
    return await client.removeTorrent("all");
  })
);

console.log("Hello via Bun!");
Pausing ubuntu-24.04-desktop-amd64.iso 2aa4f5a7e209e54b32803d43670971c4c8caaa05
Pausing ubuntu-22.04.4-desktop-amd64.iso 018e50b58106b84a42c223ccf0494334f8d55958
FetchError: [POST] "http://HOSTNAME:PORT/api/v2/torrents/delete": 400 Bad Request
FetchError: [POST] "http://HOSTNAME:PORT/api/v2/torrents/delete": 400 Bad Request
quinm0 commented 4 weeks ago

I'm back. I set up a non-bun project to test this and it seems like it's something to do with bun not working with the package. I'll see if I can mess with bunjs's default init tsconfig.json and if I find something helpful I'll report back here

scttcper commented 4 weeks ago

I've not had success with bun yet on this one, i did move towards ofetch hoping to make it easier for non-node environments but bun isn't quite there. Adding torrents fails as well.