Skip to content

get_device / update_device / delete_device hit wrong URL (/v2/devices/{id} → 404) #9

@jstrn

Description

@jstrn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions