I'm trying to acquire a valid logon session, but I get "no active session"

  • 1
  • Question
  • Updated 2 weeks ago
Beginner here, I'm following API guide to acquire a login session.
I'm testing with curl command like this


curl  https://{server-ip:server-port}/wsg/api/public/v5_1/session -k -X GET

But I get the following error:

{"message":"Current session has timed out.","errorCode":201,"errorType":"No active session"}
Photo of Alcap

Alcap

  • 3 Posts
  • 0 Reply Likes

Posted 2 weeks ago

  • 1
Photo of Jamie Walmsley

Jamie Walmsley

  • 18 Posts
  • 3 Reply Likes
Hi,

You need to be doing sending a POST rather than a GET and you also need to pass in JSON for the username/pass

data = {    "username": username,
                "password": password,
                "timeZoneUtcOffset": "+00:00"
        }
Photo of Alcap

Alcap

  • 3 Posts
  • 0 Reply Likes
Hi, I tried like you said, specifying also Content-type it seems to work!
curl  https://{ip:port}/wsg/api/public/v5_1/session -k -X POST --data '{"username":"admin","password":"Mypass.1","timeZoneUtcOffset":"+01:00"}' -H 'Content-type: application/json'
thank you
Photo of Jamie Walmsley

Jamie Walmsley

  • 18 Posts
  • 3 Reply Likes
No problems!

Once you logon it'll give you back a session ID which needs to be passed with every API call along with the content type so for example;

{'Content-Type': 'application/json;charset=UTF-8','Cookie': 'JSESSIONID='GDHDHDAAA'}