0
Votes

Powershell API

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.
 
0
Votes

Powershell API

This thread has been locked for further replies. You can start a new thread to share your ideas or ask questions.
Powershell API
Powershell API
2023-08-24 18:08:18 - last edited 2023-08-25 08:55:42
Hardware Version: V5
Firmware Version: 5.9.32

Hello,

Help understand how to make a request correctly. API documentation does not help in any way, everything is described very briefly. What is exactly the path of request and connection?

 

An example of a request:

Invoke-RestMethod -Uri "${OMADA_URL}/${CONTROLLER_ID}/api/v2/sites/Default/devices" -Method Get -ContentType "application/json" -Headers $CsrfTokenHeader -UseBasicParsing

 

 

 

 

HTML text issues to me for any request:

 

 

Fehler

#1
Options
2 Reply
Re:Powershell API
2023-08-25 08:57:28 - last edited 2023-08-25 08:57:43

Hello @cht3

 

Thank you for your valuable feedback.

I've recorded this request and will report it to the developer team for attention.

Best Regards! >> Omada EAP Firmware Trial Available Here << >> Get the Latest Omada SDN Controller Releases Here << *Try filtering posts on each forum by Label of [Early Access]*
#2
Options
Re:Powershell API
2024-02-29 09:51:20

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&currentPageSize=1000" -Method Get -Headers $RequestHeaders -WebSession $OmadaSession

#3
Options

Information

Helpful: 0

Views: 494

Replies: 2

Voters 0

No one has voted for it yet.