Am I using the API wrong?

Started by verfluchten, November 16, 2024, 10:41:05 PM

Previous topic - Next topic
I registered a user for API access, plugged its key and secret into curl, and got nowhere:

$ curl -k "https://xx.xx.xx.xx/api/core/backup/providers/?key=ABC&secret=XYZ"
{"message":"controller OPNsense\\Core\\Api\\BackupController not found","status":400}$
$ curl -k "https://xx.xx.xx.xx/api/core/firmware/status?key=ABC&secret=XYZ"
$

You may want to change your format, you are getting a 400 error, so your request is incorrect:
    curl  -k -u user:secret  https://X.X.X.X/api/core/backup/providers
Response:
    {"items":{"this":{"description":"This Firewall","dirname":"\/conf\/backup"}}}

The HTTP 400 Bad Request client error response status code indicates that the server would not process the request due to something the server considered to be a client error.

Quote from: peskytech on November 21, 2024, 03:44:20 PM
You may want to change your format, you are getting a 400 error, so your request is incorrect:
    curl  -k -u user:secret  https://X.X.X.X/api/core/backup/providers
Response:
    {"items":{"this":{"description":"This Firewall","dirname":"\/conf\/backup"}}}

The HTTP 400 Bad Request client error response status code indicates that the server would not process the request due to something the server considered to be a client error.

With your command format, I still get the same error 400 controller not found. Nothing changed.



I tried with 24.7.8 but it should be around for a while.
Hardware:
DEC740

Quote from: Monviech (Cedrik) on November 21, 2024, 06:46:38 PM
I tried with 24.7.8 but it should be around for a while.

Does the API work at all in 21.7.8? Upgrading is not an option.

You probably need the os-api-backup plugin on older versions, if it exists in yours.

https://forum.opnsense.org/index.php?topic=18218.0
Hardware:
DEC740

Quote from: Monviech (Cedrik) on November 22, 2024, 06:46:50 AM
You probably need the os-api-backup plugin on older versions, if it exists in yours.

https://forum.opnsense.org/index.php?topic=18218.0

That was the first thing that I've done before trying to use the API.