Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use Create_WLAN #159

Closed
bill-cli opened this issue May 25, 2022 · 8 comments
Closed

Unable to use Create_WLAN #159

bill-cli opened this issue May 25, 2022 · 8 comments

Comments

@bill-cli
Copy link

Attempting to create a new WLAN according to documentation in client.php. See following code:

/**
 * PHP API usage example
 *
 * contributed by: Art of WiFi
 * description:    example basic PHP script to create a new site, returns true upon success
 */

/**
 * using the composer autoloader
 */
// require_once 'vendor/autoload.php';
require_once 'C:/Users/admin/Downloads/UniFi-API-client-1.1.79/src/client.php';
/**
 * include the config file (place your credentials etc. there if not already present)
 * see the config.template.php file for an example
 */
require_once '../config.php';

/**
 * we use the default site in the initial connection
 */
/**
 * the site to use to log in to the controller
 */
$site_id = 'default';

/**
 * description of the new site
 */
$name ='APITest';
$x_passphrase ='PlacePasswordHere';
$usergroup_id ='id from list_usergroup';
$wlangroup_id ='id from list_wlan_group';
/*$enabled = true;
$hide_ssid = false; 
$is_guest = false; 
$security = 'open'; 
$wpa_mode = 'wpa2'; 
$wpa_enc = 'ccmp'; 
$vlan_enabled = null; 
$vlan_id = null; 
$uapsd_enabled = false; 
$schedule = [];
$schedule_enabled = false;
$ap_group_ids = null; */

/**
 * initialize the UniFi API connection class and log in to the controller and do our thing
 */
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion);
$loginresults     = $unifi_connection->login();
$results          = $unifi_connection->create_wlan($name, $x_passphrase, $usergroup_id, $wlangroup_id/*, $enabled, $hide_ssid, $is_guest, $security, $wpa_mode, $wpa_enc, $vlan_enabled, $vlan_id, $uapsd_enabled,$schedule,$schedule_enabled,$ap_group_ids*/);
$debug			  = $unifi_connection->get_debug();
/**
 * provide feedback in json format
 */
echo json_encode($results, JSON_PRETTY_PRINT);
echo json_encode($debug, JSON_PRETTY_PRINT);

Debug is enabled. This function results in the output "false", debug output is also "false".

We tailed the logs in the docker container running the controller (7.1.65) and the server.log file generates this message:

<webapi-83> WARN sanitize - Invalid key exists in WlanConf payload, key=wlangroup_id

@malle-pietje
Copy link
Collaborator

malle-pietje commented May 25, 2022

Which value are you passing as the wlangroup_id?

@bill-cli
Copy link
Author

bill-cli commented May 26, 2022 via email

@malle-pietje
Copy link
Collaborator

Ok, understood, just checking. I don’t have the time at the moment but need to check if anything changed with this route for the latest controller versions. Maybe that parameter is no longer needed or renamed.

@karpiatek
Copy link

karpiatek commented Aug 19, 2022

Well, starting from version 6 of the UniFi controller, there is no longer such parameter as wlangroup_id.

@malle-pietje
Copy link
Collaborator

If anyone is willing to submit a pull request or share a code change here I will test and incorporate it in the mainstream package.

@OrionTheGiant
Copy link

I watched the browser network console when adding a new WiFi network on version 7.2.92 of the controller application and it looks like the API endpoint may have changed as well. The POST is going to /rest/wlanconf instead of /add/wlanconf in addition to wlangroup_id not being included. I'll try to test the changes and make a pull request this week.

@OrionTheGiant
Copy link

Removing the wlangroup_id and changing the API endpoint worked. Pull request in #169

@swapnildevstree
Copy link

swapnildevstree commented Dec 21, 2023

Can anyone please give complete working example of the Latest function and code without wlan group id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants