Hi Jianxin/Mike/Chris,
It is not documented yet (we will add into the Release Bulletin right away), but the beta version already allows you to get all sessions or kill a session.
1,Call the /api/custom/getAllsessions to get all sessions;
2,Call the /api/custom/KillSession to kill a session of a given sessionid;
3,The session information returned from PowerServer is as below:
[{"sessionid":"85b78052-8692-4281-82e9-dbbefed31055","sessionstate":2,"createtime":"2021-05-06T03:35:30.7323321Z","lastvisittime":"2021-05-06T03:39:25.4715132Z"},{"sessionid":"ca54aa7d-5fd6-429a-a2c0-494eb3be820d","sessionstate":2,"createtime":"2021-05-06T03:35:21.0329275Z","lastvisittime":"2021-05-06T03:35:24.5604784Z"}]
Here are the sample scripts.
//-------------------------------------getSession-----------------------------------------
httpclient lhc_client
string ls_url
string ls_json
lhc_client = create httpclient
//GetSessions
ls_url = "http://localhost:5000/api/custom/getAllsessions"
//You may need to change to the actual ipaddress:port
//If there are multiple PowerServers, you can get the sessions separately for each server.
//lhc_client.SetRequestHeader("Authorization", $token, true) //If authorization is enabled
lhc_client.sendrequest("Get",ls_url)
if lhc_client.getresponsestatuscode() = 200 then
lhc_client.getresponsebody(ls_json)
//parse the json
wf_getsessions(ls_json)
end if
//-------------------------------------------------------------------------------------------------
//-------------------------------------killSession-----------------------------------------------
httpclient lhc_client
string ls_url
string ls_sessionid
lhc_client = create httpclient
//GetSessions
//lhc_client.SetRequestHeader("Authorization", $token, true) //If authorization is enabled
ls_url = "http://localhost:5000/api/custom/KillSession"
ls_sessionid = lb_sessionlist.selecteditem()
ls_url += "/"+ls_sessionid
lhc_client.sendrequest("post",ls_url)
if lhc_client.getresponsestatuscode() = 200 then
messagebox("succeed",ls_sessionid +" was killed")
end if
//-------------------------------------------------------------------------------------------------------------------
Best regards, Julie
JX