FreeNAS API system/version Error

Status
Not open for further replies.

tjvanpat

Dabbler
Joined
Mar 2, 2014
Messages
16
I'm just beginning to try out using the FreeNAS API, and it appears that there's something special about getting the version.

The following is...
Code:
import json

import requests
r = requests.get(
  'http://192.168.1.140/api/v1.0/system/advanced/',
  auth=('root', 'password'),
)
print r.text


...is able to correctly return the "Advanced" data:
Code:
{"adv_advancedmode": false, "adv_anonstats": true, "adv_anonstats_token": "", "adv_autotune": false, "adv_consolemenu": true, "adv_consolemsg": false, "adv_consolescreensaver": false, "adv_debugkernel": false, "adv_motd": "Welcome to FreeNAS", "adv_powerdaemon": false, "adv_serialconsole": false, "adv_serialport": "0x2f8", "adv_serialspeed": "9600", "adv_swapondrive": 2, "adv_traceback": true, "adv_uploadcrash": true, "id": 1}


However, the following to get the "version" data...
Code:
import json
import requests
r = requests.get(
  'http://192.168.1.140/api/v1.0/system/version/',
  auth=('root', 'password'),
)
print r.text


...returns the login page for some reason:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr">
<head>
    <title></title>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<style type="text/css">
    @import "/dojango/dojo-media/release/1.9.2/dojo/resources/dojo.css?cache=";
    @import "/dojango/dojo-media/release/1.9.2/dijit/themes/claro/claro.css?cache=";
    @import "/static//lib/js/dgrid/css/skins/claro.css?cache=";
</style>
<script type="text/javascript">
    var dojoConfig = {
        has: {
          "dojo-undef-api": true
        },
        isDebug: true,
        parseOnLoad: true,
        baseUrl: "/dojango/dojo-media/release/1.9.2/dojo",
        async: true,
        cacheBust: '',
        packages: [
        {name: "freeadmin", location: "/static/lib/js/freeadmin"},
        {name: "dgrid", location: "/static/lib/js/dgrid"},
        {name: "xstyle", location: "/static/lib/js/xstyle"},
        {name: "put-selector", location: "/static/lib/js/put-selector"}
        ]
    };
    var CSRFToken = 'keMfqGe9bzkbqcyvOzma59pUw1k0Sfhw';
</script>
[...Much more HTML follows, including the following...]
<!-- THIS IS A LOGIN WEBPAGE -->
[...Then more HTML...]


Any ideas why I'm unable to get the system version using the FreeNAS API, but it instead sends a login page?
 
Last edited:

William Grzybowski

Wizard
iXsystems
Joined
May 27, 2011
Messages
1,754
I believe your FreeNAS version does not implement this API endpoint. Try again with a nightly image.
 

tjvanpat

Dabbler
Joined
Mar 2, 2014
Messages
16
I'm currently running FreeNAS-9.2.1.6-RELEASE-x64 (ddd1e39). Is there a way to tell which commands this version accepts, or just try them out and see what I get? I don't feel comfortable moving my servers on to a nightly build just for the API accesses.
 
Status
Not open for further replies.
Top