### PowerShell Example # set variables $OMADA_URL = "https://omada.example.com:8043" $USERNAME = "admin" $PASSWORD = "test12345" # get controller id from the API $CONTROLLER_ID = (Invoke-RestMethod -Uri "${OMADA_URL}/api/info" -Method Get -UseBasicParsing).result.omadacId # set the login request body as json $loginRequestBody = @{ username = $USERNAME password = $PASSWORD } | ConvertTo-Json # login, get token, set a session variable $loginResponse = Invoke-RestMethod -Uri "${OMADA_URL}/${CONTROLLER_ID}/api/v2/login" -Method Post -ContentType "application/json" -Body $loginRequestBody -SessionVariable OmadaSession # extract the token and create a variable for the headers $TOKEN = $loginResponse.result.token $RequestHeaders = @{ "Csrf-Token" = $TOKEN "Content-Type" = "application/json" } # validate login Invoke-RestMethod -Uri "${OMADA_URL}/${CONTROLLER_ID}/api/v2/loginStatus?token=${TOKEN}" -Method Get -Headers $RequestHeaders -WebSession $OmadaSession # example to get info on the current user Invoke-RestMethod -Uri "${OMADA_URL}/${CONTROLLER_ID}/api/v2/users/current?token=${TOKEN}¤tPage=1¤tPageSize=1000" -Method Get -Headers $RequestHeaders -WebSession $OmadaSession