How can I get session detail (i.e. user id or person id) for an authenticated user?

Hi,

To get session detail, I called an API end /api/getSession after I successfully get authenticated. But I am not able to get the session detail. Please see the request-response log below.

Request

GET /openboxes/api/getSession HTTP/1.1
Host: localhost:8080
Content-Type: application/json
cookie: JSESSIONID=4D022C5846C6A707CBB3E01A3C67ACC5
Cache-Control: no-cache
Postman-Token: df0997f9-7387-421b-a1fb-0282b5c89b70

Response

{
    "errorCode": 500,
    "errorMessage": "Cannot get property 'supportedActivities' on null object"

}

Is there anything missed in my request? Thank you in advance.

Regards,
Andualem W.

Yeah, this is a bug. The /api/getSession API assumes that you’ve logged in with a location. I’ll add a ticket to fix the bug in /api/getSession, but as a workaround you can just ensure that your current session is associated with a location.

POST /api/login
{ 
    "username": "<username>",
    "password": "<password>",
    "location": "<location id>"
}

If you’re already logged in and want to switch locations, you can send the following request to change your current location.

POST /api/chooseLocation/:id

Justin

Thank you Justin. I tried it with the workaround solution. Now I am able to get the session detail for already login users. Thanks!