Unable to Run Reports via Calls to API #2227

Closed
opened 2025-12-29 17:23:56 +01:00 by adam · 2 comments
Owner

Originally created by @bdlamprecht on GitHub (Dec 19, 2018).

Environment

  • Python version: 3.6.5
  • NetBox version: 2.5.1

Steps to Reproduce

Create a sample report such as the documented (pending update to use v2.5 variables) example.

Attempt to get the reports from the API using the following code:

$ curl -X GET "http://netbox.local/api/extras/reports/" -H "accept: application/json; indent=2"

This results in the following output:

[
  {
    "module": "devices",
    "name": "DeviceConnectionsReport",
    "description": "Validate the minimum physical connections for each device",
    "test_methods": [
      "test_console_connection",
      "test_power_connections"
    ],
    "result": {
      "url": "http://netbox.local/api/extras/reports/devices.DeviceConnectionsReport/",
      "created": "2018-12-19T22:09:30.534847Z",
      "user": null,
      "failed": true
    }
  }
]

There is no id assigned to this report (or other future reports which may be created).

When attempting to run the report using the API, the only call I can locate (using swagger) is:

/api/extras/reports/{id}/run/

Guessing at using the id=1 doesn't work and the results is as follows:

curl -X POST "http://netbox.local/api/extras/reports/1/run/" -H "accept: application/json; indent=2" -H "Authorization: Token $NB_TOKEN"
{
  "detail": "Not found."
}

Expected Behavior

  1. An id should be associated with each report to then be able to run it via the API.
  2. The report to actually run correctly similar to being executed in the WebUI.

Observed Behavior

Explained above.

Originally created by @bdlamprecht on GitHub (Dec 19, 2018). ### Environment * Python version: 3.6.5 * NetBox version: 2.5.1 ### Steps to Reproduce Create a sample report such as the [documented](https://netbox.readthedocs.io/en/stable/additional-features/reports/#writing-reports) (pending update to use `v2.5` variables) example. Attempt to get the reports from the API using the following code: ``` $ curl -X GET "http://netbox.local/api/extras/reports/" -H "accept: application/json; indent=2" ``` This results in the following output: ``` [ { "module": "devices", "name": "DeviceConnectionsReport", "description": "Validate the minimum physical connections for each device", "test_methods": [ "test_console_connection", "test_power_connections" ], "result": { "url": "http://netbox.local/api/extras/reports/devices.DeviceConnectionsReport/", "created": "2018-12-19T22:09:30.534847Z", "user": null, "failed": true } } ] ``` There is no `id` assigned to this `report` (or other future `reports` which may be created). When attempting to run the report using the API, the only call I can locate (using `swagger`) is: ``` /api/extras/reports/{id}/run/ ``` Guessing at using the `id=1` doesn't work and the results is as follows: ``` curl -X POST "http://netbox.local/api/extras/reports/1/run/" -H "accept: application/json; indent=2" -H "Authorization: Token $NB_TOKEN" { "detail": "Not found." } ``` ### Expected Behavior 1. An `id` should be associated with each report to then be able to run it via the API. 2. The report to actually run correctly similar to being executed in the WebUI. ### Observed Behavior Explained above.
adam closed this issue 2025-12-29 17:23:57 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 21, 2018):

Reports do not have numeric keys as they are not database objects. To reference an individual report, access it as <module>.<name>. In your example, this would be /api/extras/reports/devices.DeviceConnectionsReport/.

@jeremystretch commented on GitHub (Dec 21, 2018): Reports do not have numeric keys as they are not database objects. To reference an individual report, access it as `<module>.<name>`. In your example, this would be `/api/extras/reports/devices.DeviceConnectionsReport/`.
Author
Owner

@bdlamprecht commented on GitHub (Dec 21, 2018):

I guess this has something to do with the issues to date with the Swagger API browser mentioned in #2705 as id is the only format is currently allows.

@bdlamprecht commented on GitHub (Dec 21, 2018): I guess this has something to do with the issues to date with the Swagger API browser mentioned in #2705 as `id` is the only format is currently allows.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2227