OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • Documentation and Translation (Moderator: fabian) »
  • API: SMART Plugin docs specify POST requests to api, but no parameters specified
« previous next »
  • Print
Pages: [1]

Author Topic: API: SMART Plugin docs specify POST requests to api, but no parameters specified  (Read 9286 times)

nerdovic

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
API: SMART Plugin docs specify POST requests to api, but no parameters specified
« on: April 22, 2021, 01:43:22 pm »
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:
Code: [Select]
{
  "message": "Unable to run info action"
}

When I do a POST, I don't even get json as return, just a HTTP 411 error:
Code: [Select]
<?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:
Code: [Select]
curl -k -u "<api_user>":"<api_pass>" https://<opnsense>/api/smart/service/listPOST:
Code: [Select]
curl -XPOST -k -u "<api_user>":"<api_pass>" https://<opnsense>/api/smart/service/list
Logged

Whaw

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
Re: API: SMART Plugin docs specify POST requests to api, but no parameters specified
« Reply #1 on: January 07, 2024, 10:46:36 am »
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
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • English Forums »
  • Documentation and Translation (Moderator: fabian) »
  • API: SMART Plugin docs specify POST requests to api, but no parameters specified
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2