Art-of-WiFi / UniFi-API-client

A PHP API client class to interact with Ubiquiti's UniFi Controller API
MIT License
1.09k stars 217 forks source link

Unable to create network #160

Closed pekadee closed 4 months ago

pekadee commented 2 years ago

Hello, I am trying to create a network via API. My controller version is 6.2.23. Here's what I've got:

<?php

require_once 'vendor/autoload.php';

require_once 'config.php';

$site_id = 'lj26zn2e';

$data = array(
        "attr_no_delete"=> false,
        "attr_hidden_id"=> "Test1",
        "name"=> "Test1",
        "site_id" => "lj26zn2e",
        "vlan_enabled" => true,
        "purpose" => "corporate",
        "ip_subnet" => "10.10.0.8/28",
        "ipv6_interface_type" => "none",
        "is_nat" => true,
        "dhcpdv6_enable" => false,
        "ipv6_ra_enabled" => false,
        "lte_lan_enabled" => true,
        "auto_scale_enabled" => true,
        "networkgroup" => "LAN"
);
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion);
$loginresults     = $unifi_connection->login();
$result          = $unifi_connection->create_network($data);

/**
 * provide feedback in json format
 */

echo json_encode($result, JSON_PRETTY_PRINT);

Output of that file is just "false". I've also found this log:

[2022-06-01T12:08:34,487] <webapi-151> WARN  sanitize - Invalid key exists in NetworkConf payload, key=dhcpdv6_enable

My overall goal is to create multiple networks on my controller. Can I do this in one php file? And can you tell me what am I doing wrong? Thanks in advance

oza4h07 commented 6 months ago

Have you found a way to create a network using API with either a 6.2.23 controller or different one ?