API: SMART Plugin docs specify POST requests to api, but no parameters specified

Started by nerdovic, April 22, 2021, 01:43:22 PM

Previous topic - Next topic
Hello Everyone,
this is my first post to this forum, and I hope I've picked the right area to do so.

I am a bit confused about the API docs of the SMART plugin (https://docs.opnsense.org/development/api/plugins/smart.html). The docs tell me that a POST request is required to query this part of the API, but there are no Parameters etc. specified that have to be POSTed.

I feel like the Docs are lacking some information how to properly query the SMART plugin API.
Thank you for your insights!

What I've tried:


I tried with GET at first, but this just brings up an error message:

{
  "message": "Unable to run info action"
}


When I do a POST, I don't even get json as return, just a HTTP 411 error:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>411 Length Required</title>
</head>
<body>
  <h1>411 Length Required</h1>
</body>
</html>


I am testing with curl like the example from the how-tos (https://docs.opnsense.org/development/how-tos/api.html#using-curl):
GET: curl -k -u "<api_user>":"<api_pass>" https://<opnsense>/api/smart/service/list
POST: curl -XPOST -k -u "<api_user>":"<api_pass>" https://<opnsense>/api/smart/service/list

Hi,

Just found the solution reading the html of the web interface.
curl -k -u "$key":"$secret" https://opnsenseip:443/api/smart/service/info -X POST -H "Content-Type: application/json" -d '{"type": "A","device": "nvme0"}'

Types:
value="i" Info
value="H" Health
value="c" SMART Capabilities
value="A" Attributes
value="a" All

Greets
Jef