vche/pycliarr

MethodNotAllowed for issuing "delete_queue"

Closed this issue · 10 comments

I ran the following command:
self.sonarr_node.delete_queue(1350031771)

Trying to delete something from the queue.

I get this stack trace:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/telegram/ext/dispatcher.py", line 447, in process_update
handler.handle_update(update, self, check, context)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/telegram/ext/handler.py", line 160, in handle_update
return self.callback(update, context)
File "/Users/marco/Documents/GitHub/pixlovarr/./app/pixlovarr.py", line 1252, in deleteQueueItem
res = self.sonarr_node.delete_queue(data[2])
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycliarr/api/base_media.py", line 168, in delete_queue
return self.request_delete(self.api_url_queue, data)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycliarr/api/base_api.py", line 106, in request_delete
return self.request("DELETE", path, url_params=url_params)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycliarr/api/base_api.py", line 81, in request
raise CliServerError(
pycliarr.api.exceptions.CliServerError: Error from server http://192.168.178.7:8989/api//queue, status: 405, msg: '{\n "message": "MethodNotAllowed"\n}'

My Questions:

Why do I get an "{\n "message": "MethodNotAllowed"\n}'". -->> I read something on Internet the JSON is not correct.

The URL has a double "//" in the URL. I reckon is not correct.
http://192.168.178.7:8989/api//queue. <<-- double // in here

This not the problem of "Method on allowed" (I tested it)

But I think in base_media.py :: api_url_base = "/api/" -->> api_url_base = "/api"

vche commented

double "/" are fine in URLs. Method not allowed means the HTTP method (put/get/post/delete) used for this url is not accepted by sonarr/radarr.

Can you enable the debug mode ( -din the cli, or logging.basicConfig(level=logging.DEBUG)in the code), and provide the http request sent to sonarrr ?

2021-05-15 16:37:58,427 - pycliarr.api.base_api - DEBUG - Request sent: DELETE http://192.168.178.7:8989/api//queue params: {'id': 1350031771} data: None
2021-05-15 16:37:58,433 - urllib3.connectionpool - DEBUG - http://192.168.178.7:8989 "DELETE /api//queue?id=1350031771 HTTP/1.1" 405 None
2021-05-15 16:37:58,436 - telegram.ext.dispatcher - ERROR - No error handlers are registered, logging exception.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/telegram/ext/dispatcher.py", line 447, in process_update
handler.handle_update(update, self, check, context)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/telegram/ext/handler.py", line 160, in handle_update
return self.callback(update, context)
File "/Users/marco/Documents/GitHub/pixlovarr/./app/pixlovarr.py", line 1252, in deleteQueueItem
res = self.sonarr_node.delete_queue(int(data[2]))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycliarr/api/base_media.py", line 168, in delete_queue
return self.request_delete(self.api_url_queue, data)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycliarr/api/base_api.py", line 106, in request_delete
return self.request("DELETE", path, url_params=url_params)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pycliarr/api/base_api.py", line 81, in request
raise CliServerError(
pycliarr.api.exceptions.CliServerError: Error from server http://192.168.178.7:8989/api//queue, status: 405, msg: '{\n "message": "MethodNotAllowed"\n}'

vche commented

That seems correct and conform to sonarr api.
Does it work with radarr ?

Radarr same problem

vche commented

I'll test on my config when I can, but requests look correct.

thanks

Here this "script" I test this with.

from pycliarr.api import (
    SonarrCli
)
import logging

logging.basicConfig(
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    level=logging.DEBUG)

sonarr_node = SonarrCli('http://192.168.178.7:8989',
                        '2c9e7044203a44bd99e20e45fc7411a3')

res = sonarr_node.delete_queue(1350031771)

print(res)
vche commented

thanks for the additional info ! this helps