The following shell code makes a successful connection to the controller. I was also able to read some user type data and some other little things. But I need a list of profiles with addresses allowed in this way. Using the manual, my request gives a response that the page is not correct. I also tried using OpenApi, which also did not produce results, so the connection does not even occur. Can someone help with this and point me to the right decision.:
### PowerShell Example
# set variables
$OMADA_URL = "https://omada-seite"
$USERNAME = "user"
$PASSWORD = "pass"
# 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" -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" -Method Get -Headers $RequestHeaders -WebSession $OmadaSession
# Sitens
$result = Invoke-RestMethod -Uri "${OMADA_URL}/${CONTROLLER_ID}/api/v2/sites" -Method Get -Headers $RequestHeaders -WebSession $OmadaSession
#deviceslist
Invoke-RestMethod -Uri "${OMADA_URL}/${CONTROLLER_ID}/api/v2/sites/638ef74e14f65e09652531f5/devices" -Method Get -Headers $RequestHeaders -WebSession $OmadaSession
#settings (but not all)
Invoke-RestMethod -Uri "${OMADA_URL}/${CONTROLLER_ID}/api/v2/sites/638ef74e14f65e09652531f5/setting?currentPage=1¤tPageSize=1000" -Method Get -Headers $RequestHeaders -WebSession $OmadaSession