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

SynologyDSMAPIErrorException (400) - "Execution failed" #159

Open
Perzan opened this issue Feb 8, 2021 · 1 comment
Open

SynologyDSMAPIErrorException (400) - "Execution failed" #159

Perzan opened this issue Feb 8, 2021 · 1 comment

Comments

@Perzan
Copy link

Perzan commented Feb 8, 2021

from synology_dsm import SynologyDSM as sdsm
from synology_dsm.api.surveillance_station import SynoSurveillanceStation

from getpass import getpass

class Camera:
    api:SynoSurveillanceStation
    id:int

    def __init__(self, api:SynoSurveillanceStation, id:int):
        self.api = api
        self.id = id
    
    @property
    def current_frame(self):
        self.api.capture_camera_image(self.id)

USERNAME = "admin"
PASSWORD = getpass(f"Password for \"{USERNAME}\" > ")

PORT = "5001"

def getapi(host:str) -> SynoSurveillanceStation:
    return sdsm(
        host,
        PORT,
        USERNAME,
        PASSWORD,
        verify_ssl=False,
        use_https=True
    ).surveillance_station

syn01 = getapi("syn01")
syn02 = getapi("syn02")

lobby = Camera(syn01, 10)
corner = Camera(syn02, 23)

current = lobby.current_frame

print(type(current))

This code results in the following error:

Traceback (most recent call last):
  File "c:\Users\Perzan\Desktop\synology-test\test.py", line 39, in <module>
    current = lobby.current_frame
  File "c:\Users\Perzan\Desktop\synology-test\test.py", line 16, in current_frame
    self.api.capture_camera_image(self.id)
  File "C:\Users\Perzan\Desktop\synology-test\lib\site-packages\synology_dsm\api\surveillance_station\__init__.py", line 92, in capture_camera_image
    return self._dsm.get(
  File "C:\Users\Perzan\Desktop\synology-test\lib\site-packages\synology_dsm\synology_dsm.py", line 194, in get
    return self._request("GET", api, method, params, **kwargs)
  File "C:\Users\Perzan\Desktop\synology-test\lib\site-packages\synology_dsm\synology_dsm.py", line 260, in _request
    raise SynologyDSMAPIErrorException(
synology_dsm.exceptions.SynologyDSMAPIErrorException: {'api': 'SYNO.SurveillanceStation.SnapShot', 'code': 400, 'reason': 'Execution failed', 'details': {'param1': '', 'param2': ''}}

I know that this probably doesn't have anything to do with this library since it is an SynologyDSMAPIErrorException, but I wasn't sure what to do from here. Am I using the wrong ID for each camera? When I logged into the interface in my browser, I saw the camera identifier followed by a hyphen and the name of the camera. I used those identifiers in this script.

@Perzan
Copy link
Author

Perzan commented Feb 8, 2021

I was skimming through some random PDF I found on Google and looked at page 274 and compared what I saw to the code for the capture_camera_image method. I noticed that the method code does not use the dsId field. I don't think this is why there is a problem, but I thought I would share anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant