×
Menu
Index

Login

 

Description

 
POST a login request to the SoftNAS Cloud® API, creating an active session with the SoftNAS Cloud® Admin Server.
 
POST login username password
 
Request
 
Login is based on the Standard Request Structure.
 
For specific parameter definitions, see section Parameters
 
Parameter
Required?
username
Y
password
Y
Session ID
N
Base URL
N
pretty_print
N
 
Example
 
Login using PHP.
 
<?php
 
    $mypath = getcwd();
 
    $mypath = preg_replace('/\\\\/', '/', $mypath);
 
    $rand = rand(1, 15000);
 
    $cookie_file_path = "$mypath/cookies/cookie$rand.txt";
 
    $data = array(
 
     'username' => 'softnas',
 
     'password' => 'Pass4W0rd'
 
     );
 
    $ch = curl_init();
 
    curl_setopt($ch, CURLOPT_URL, "https://example.com/softnas/login.php");
 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
    curl_setopt($ch, CURLOPT_POST, true);
 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE );
 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE );
 
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);   // Cookie management.
 
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
 
    curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
 
 
    $output = curl_exec($ch);
 
    $info = curl_getinfo($ch);
 
    curl_close($ch);
 
    echo $info;
 
 

Return Values

 
 
Example Output
{
"result": {},
"session_id": 8062, 
"success": true
}
 
 
Made with help of Dr.Explain
Copyright (c) SoftNAS LLC