Bug
NinjaRMMClient.get_device(device_id) (and the related update_device / delete_device methods) request GET /v2/devices/{id} (plural), which the NinjaOne API returns 404 Not Found for.
The correct, documented endpoint is GET /v2/device/{id} (singular). Every other device_* method in the same client file already uses the singular form (/v2/device/{id}/jobs, /v2/device/{id}/disks, /v2/device/{id}/network-interfaces, /v2/device/{id}/windows-services, etc.), so this is just an inconsistency in three methods.
Reproduction
from ninjapy import NinjaRMMClient
client = NinjaRMMClient(
token_url=..., client_id=..., client_secret=..., scope=..., base_url=...,
)
client.get_device(3395)
# ninjapy.client - ERROR - HTTPError encountered:
# 404 Client Error: Not Found for url: https://api.ninjarmm.com/v2/devices/3395
# raises Resource not found
The same call succeeds against the singular endpoint:
client._request(\"GET\", \"/v2/device/3395\") # 200 OK, returns the device dict (incl. ``offline``)
Affected versions
Confirmed on ninjapy==0.1.3.
Affected lines (ninjapy/client.py)
- L713:
return self._request(\"GET\", f\"/v2/devices/{device_id}\", params=params) (get_device)
- L726:
return self._request(\"PATCH\", f\"/v2/devices/{device_id}\", json=kwargs) (update_device)
- L735:
self._request(\"DELETE\", f\"/v2/devices/{device_id}\") (delete_device)
Suggested fix
Change all three occurrences from /v2/devices/{device_id} to /v2/device/{device_id} to match the rest of the per-device endpoints and the NinjaOne API spec.
Happy to send a PR.
Bug
NinjaRMMClient.get_device(device_id)(and the relatedupdate_device/delete_devicemethods) requestGET /v2/devices/{id}(plural), which the NinjaOne API returns 404 Not Found for.The correct, documented endpoint is
GET /v2/device/{id}(singular). Every otherdevice_*method in the same client file already uses the singular form (/v2/device/{id}/jobs,/v2/device/{id}/disks,/v2/device/{id}/network-interfaces,/v2/device/{id}/windows-services, etc.), so this is just an inconsistency in three methods.Reproduction
The same call succeeds against the singular endpoint:
Affected versions
Confirmed on
ninjapy==0.1.3.Affected lines (
ninjapy/client.py)return self._request(\"GET\", f\"/v2/devices/{device_id}\", params=params)(get_device)return self._request(\"PATCH\", f\"/v2/devices/{device_id}\", json=kwargs)(update_device)self._request(\"DELETE\", f\"/v2/devices/{device_id}\")(delete_device)Suggested fix
Change all three occurrences from
/v2/devices/{device_id}to/v2/device/{device_id}to match the rest of the per-device endpoints and the NinjaOne API spec.Happy to send a PR.