Closed andreasloe closed 1 year ago
Which dashboard are you referring to? To get the sites’ details you can best first call list_sites()
.
Please also share more details such as controller version and type (UniFi OS or not). These functions still work fine for us on the latest versions.
Malle-pietje: Thank you very much for sour support and sorry for providing so little information in the first post.
I am using a UniFi OS UCK G2 Plus 2.5.11. In order to block a client I am connecting to Unifi Network 7.2.94. The dashboard I am connecting to is available at https://
Sicne I am not running php/python yet but rely on the GUI, I do not exactly know where I find the list_sties. I have one network 192.168.2.0/24 and three Wifi-networks. The AP use the newest firmware (6.2.35). Is there anything more I can do?
Ok, no problem.
In your case the "site id" is "default" and that should work fine. If you wish to better understand the UniFi controller API and the data it exposes, I highly recommend installing the API Browser tool from here: https://github.com/Art-of-WiFi/UniFi-API-browser
Thanks, I tried the API browser before and got a 500 error despite having configured it using the GUI credentials:
[Tue Sep 27 11:03 2022] [php7:error] [pid 23976] [client 192.168.2.XX:50387] PHP Fatal error: Uncaught Error: Call to undefined function curl_version() in /var/www/html/UniFi-API-browser/common.php:13\nStack trace:\n#0 /var/www/html/UniFi-API-browser/index.php(38): require_once()\n#1 {main}\n thrown in /var/www/html/UniFi-API-browser/common.php on line 13
And I have
curl ist schon die neueste Version (7.64.0-4+deb10u3).
PS The error remains after
sudo apt-get install php-curl
PPS Got it. I needed several commands in case someone runs into the same problem:
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install curl
sudo apt-get install php-curl
sudo service apache2 restart
And regarding the first question I now have an answer:
Error loading sites or no sites available
Hmm. I am back on square one. Although the log says
192.168.2.XX - - [27/Sep/2022:11:34:25 +0200] "POST /UniFi-API-browser/ajax/fetch_sites.php HTTP/1.1" 200 401 "http://raspfhem.fritz.box/UniFi-API-browser/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
and
* We are completely uploaded and fine
What kind of credentials are you using? Does this local user have access to the Network Application for all sites?
I have two url's I am using: https://cloudkey.fritz.box/ [this is my local access] and https://unifi.ui.com/dashboard [this is the online access] and I have used all the credentials that were successful with those sites.
Only direct access will work, server-to-server communication isn't supported through unifi.ui.com. Make sure to directly connect to the CloudKey using port 443.
OK, I checked that - to no avail. I believe that I have write access and I am using the local account. Strange.
I'm afraid I can't be of any further help but something is definitely wrong with the controller or the credentials.
As a last resort you can enable debug mode in the API browser tool and share sanitized logs here.
Thanks anyway. I believe this has nothing to do with your software because I had the same problem with Perl. I will try this.
Here is the debug. I cannot see anything suspicious, unfortunately.
`* Connected to cloudkey.fritz.box (2003:cf:572f:e400:7683:XXXX:XXXX:XXXX) port 443 (#0)
ALPN, offering h2
ALPN, offering http/1.1
successfully set certificate verify locations:
CAfile: none CApath: /etc/ssl/certs
SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
ALPN, server accepted to use h2
Server certificate:
subject: CN=unifi.local
start date: Dec 29 11:50:41 2020 GMT
expire date: Apr 3 10:50:41 2023 GMT
issuer: CN=unifi.local
SSL certificate verify result: self signed certificate (18), continuing anyway.
Using HTTP2, server supports multi-use
Connection state changed (HTTP/2 confirmed)
Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
Using Stream ID: 1 (easy handle 0x214b0d0)
GET / HTTP/2 Host: cloudkey.fritz.box Accept: / Accept-Encoding: deflate, gzip
old SSL session ID is stale, removing
Connection state changed (MAX_CONCURRENT_STREAMS == 4294967295)! < HTTP/2 200 < vary: Origin < x-dns-prefetch-control: off < x-frame-options: SAMEORIGIN < strict-transport-security: max-age=15552000; includeSubDomains < x-download-options: noopen < x-content-type-options: nosniff < x-xss-protection: 1; mode=block < accept-ranges: bytes < content-type: text/html; charset=utf-8 < content-length: 595 < x-csrf-token: 1213ccf8-9d1b-43ee-bcd3-XXXXXXXXXX < x-response-time: 51ms < set-cookie: TOKEN=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT; samesite=none; secure; httponly < date: Tue, 27 Sep 2022 09:32:59 GMT `
Other than the IPv6 address I don't see anything odd...
I am just reading this website „ There are times when having the site ID as default is not going to work for you or your clients. Primarily this becomes an issue when you are utilizing the UniFi API or any other script that engages the controller address via url“
This only applies in cases where you have captive portal software connecting to multiple controllers and sites and you have more than 1 default site. Not applicable here.
Since I have (more or less) the same problem with a completely different software I suspect that Unifi is the culprit. I will now try to open a case in their forum. We can close the case here and I open it if I know more?
Ok
The commands like block or deblock do not work. I noticed that there is no site-id in dashboard anymore. Might this be the reason?