Since the 1.54 update of LibreNMS, I am having issues with retrieving device port information through the API, specifically ports which require URL Encoding (i.e Gi1/0/1).
The following json message is returned when I try to retrieve stats from https://[hostname]/api/v0/devices/[devicename]/ports/Gi1%2F0%2F5.
{
“status”: “error”,
“message”: “This API route doesn’t exist.”
}
Ports that don’t require URL Encoding are able to be returned (https://[hostname]/api/v0/devices/[devicename]/ports/vl250)
{
“status”: “ok”,
“port”: {…
},
“count”: 78
}
Has something changed in the respect to this? I have looked through the release notes and haven’t necessarily seen anything related to this listed.
I would say that the Laravel API Routing change would be consistent with what I’m seeing here.
Reading the comments in that Laravel issue, I don’t think there is much I can do except wait to see if the LibreNMS Dev’s remap API calls for port names with forward slashes to something else.
Impacted by this change as well… I guess it’s time to stop auto updates and keep libre on an old internal stable version, then run through tests before upgrading.
Unfortunately, we cannot fix or work around this. Workaround in that thread won’t work due to a conflict with the graph api url.
I will be adding the ability for those two routes to accept port_id in addition to ifName and I will make a note that ifName will not work if it contains a / in the docs. If anyone can come up with any better idea, I’m all ears.
Getting port by ID seems to be working well, I had some issues using the ifName?ifName=0/4 process which I hadn’t had time to look at why it wasn’t working correctly.
@murrant the URL I was using was https://[hostname]/api/v0/devices/[devicename]/ports/ifName/portbits/?ifName=Te1/0/1 which was returning me the following error.
However, https://[hostname]/api/v0/devices/[devicename]/ports/ifName?ifName=Te1/0/1 returned the correct information.
Using the port id for the API gets also worked (https://[hostname]/api/v0/devices/[devicename]/ports/6622/port_bits and https://[hostname]/api/v0/devices/[devicename]/ports/6622/port_bits)