The URL is wrong and you need a Bearer token not Basic authentication, also you should probably add an Accept: header, so this should work to get the JSON:
curl -s -H "Authorization: Bearer YourApiTokenHere" -H "Accept: application/json" https://portal.ampr.org/api/v1/encap/routes
The Wiki needs updating, so if you want to give it a test then let me know if the jq parsing bit works as well and I will update.
If you’re subscribed to 44Net on groups.io http://groups.io/ I posted a PHP script to download and parse the encap routes a couple of weeks ago: https://ardc.groups.io/g/44net/message/93
When I get a moment I will put that on the Wiki.
Thanks, Chris - G1FEF — ARDC Administrator
Web: https://www.ardc.net
On 25 Apr 2024, at 23:48, Andreas Ott via 44net 44net@mailman.ampr.org wrote:
I ran into the same issue earlier this year and suggested a fix on this and the wiki mailing list (before they were moved, so you may not be able to see it in archives). The change is as you suspect with the parsing argument of jq, see here in diff style format what worked for me:
# download api data with curl into a file json-data.out -cat json-data.out | jq -r '.[] | "route addprivate +cat json-data.out | jq -r '.encap[] | "route addprivate (.network)/(.maskLength) encap (.gatewayIP)"' >> encap.txt
-andreas K6OTT
On Thu, Apr 25, 2024 at 3:32 PM Lee D Bengston via 44net 44net@mailman.ampr.org wrote: Hello,
If I use the line from the Wiki below in order to retrieve the file via API (and convert it back to the text forma), I get a parsing error - presumably from jq. If I download only the file taking jq out of the equation, it's not a json file, but rather, a HTML file. I assume that's why there's a parsing error when jq reads it. Is the info from the Wiki out of date?
Thanks, Lee K5DAT
curl -s https://user:key@portal.ampr.org/api/v1/encap | jq -r '.[] | "route addprivate (.network)/(.maskLength) encap (.gatewayIP)" _______________________________________________ 44net mailing list -- 44net@mailman.ampr.org To unsubscribe send an email to 44net-leave@mailman.ampr.org