| home > API > Example > |
Example server login |
Login with POST and send credentials in the request body as
application/x-www-form-urlencoded (do not use GET).
| Field |
Content |
| Request |
POST /server/login HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: 33
user=admin&extern_password=admin
|
Note: Example only; use TLS (HTTPS) in production so the password is not sent in clear text.
|
The server rejects GET /server/login:
| Field |
Content |
| Request |
GET /server/login?user=admin&extern_password=admin HTTP/1.1 Host: localhost |
| Response header |
HTTP/1.1 400 Bad Request Server: Palo
Content-Type: text/plain;charset=utf-8 Content-Length: 64
|
| Response body |
1005;"invalid type";"GET method not allowed for /server/login"; |
|
Successful login (username and password valid):
| Field |
Content |
| Response header |
HTTP/1.1 200 OK Server: Palo
Content-Type: text/plain;charset=utf-8 Content-Length: 16
|
| Response body |
f92i;1159364625; |
Note: "f92i" is the session identifier (sid) for subsequent requests.
|
Login failed (username or password invalid):
| Field |
Content |
| Response header |
HTTP/1.1 400 Bad Request Server: Palo
Content-Type: text/plain;charset=utf-8 Content-Length: 46
|
| Response body |
1003;"illegal parameter value";"login error"; |
|
|
Request for the list of OLAP databases:
| Field |
Content |
| Request header |
GET /server/databases?sid=f92i HTTP/1.1
Host: localhost
|
|
The response of a server with two databases:
| Field |
Content |
| Response header |
HTTP/1.1 200 OK
Server: Palo
X-PALO-SV: 846931642
Content-Type: text/plain;charset=utf-8
Content-Length: 55
|
| Response body |
0;"Sample Database 1";5;1;1; 1;"a new database";0;0;2; |
Note: "846931642" is the server X-PALO-SV token.
|
The response of an empty server:
| Field |
Content |
| Response header |
HTTP/1.1 200 OK Server: Palo
Content-Type: text/plain;charset=utf-8 Content-Length: 0
|
|
Request for the list of OLAP databases using a server token:
| Field |
Content |
| Request header |
GET /server/databases?sid=f92i HTTP/1.1
Host: localhost
X-PALO-SV: 846931642
|
|
If the token is outdated:
| Field |
Content |
| Response header |
HTTP/1.1 400 Bad Request
Server: Palo
Content-Type: text/plain;charset=utf-8
Content-Length: 54
|
| Response body |
5001;"server token outdated";"server token outdated"; |
|
Example 2 |
Request for the list of dimensions of a non-existing database:
| Field |
Content |
| Request header |
GET /database/dimensions?database=2&sid=f92i HTTP/1.1 Host: localhost |
|
The response:
| Field |
Content |
| Response header |
HTTP/1.1 400 Bad Request
Server: Palo Content-Type: text/plain;charset=utf-8
Content-Length: 48 |
| Response body |
1004;"database not found";"database not found"; |
|