Original Message:
Sent: Sep 20, 2023 06:04 PM
From: scmalcom
Subject: Delete vlan and change vlan name on switch with REST API
Hi Tiffany!
For the PUT method I'm using:
http://switchIp/rest/v1/vlans
Eg.
http://10.200.0.20/rest/v1/vlans
Original Message:
Sent: Sep 20, 2023 05:37 PM
From: Tiffany.Chiapuzio-Wong
Subject: Delete vlan and change vlan name on switch with REST API
@scmalcom what URL are you using for the PUT method to update? you can find the REST API documentation on our Aruba Support Portal : https://asp.arubanetworks.com/downloads/documents/RmlsZToxYjRkNTM2OC1mNGZiLTExZTktYjQ4Zi01M2MzNDFiNjZkNmQ%3D
------------------------------
Ti Chiapuzio-Wong (they/them)
HPE Aruba Networking
Original Message:
Sent: Sep 20, 2023 02:45 PM
From: scmalcom
Subject: Delete vlan and change vlan name on switch with REST API
Yes, I save the cookie in web class after login and then I use it to call other api calls and logout.
I'm able to add new vlan, assign port to vlan, get vlans, get Mac-addresses, get ports and system info with the rest API, but not changing name on vlan or deleting a vlan.
Do you have a link to docs for v8 API?
Thanks in advance😊
Original Message:
Sent: Sep 20, 2023 02:35 PM
From: alagoutte
Subject: Delete vlan and change vlan name on switch with REST API
May be better to use v8 API (if you are using 16.10 firmware...)
you can try to look the debug (debug rest interface if remember)
on your LoginSwitch() function, you store the cookie needed for call API ?
------------------------------
PowerArubaSW : Powershell Module to use Aruba Switch API for Vlan, VlanPorts, LACP, LLDP...
PowerArubaCP: Powershell Module to use ClearPass API (create NAD, Guest...)
PowerArubaCL: Powershell Module to use Aruba Central
PowerArubaCX: Powershell Module to use ArubaCX API (get interface/vlan/ports info)..
ACEP / ACMX #107 / ACDX #1281
Original Message:
Sent: Sep 20, 2023 04:11 AM
From: scmalcom
Subject: Delete vlan and change vlan name on switch with REST API
When I now try to delete a vlan with REST API, I get http error status OK, but it doesn't actually delete the VLAN, the vlan is still on the switch and there are no ports associated to the vlan.
This is my code:
bool _Switch::deleteVlan(VlanData^ vlan) { loginSwitch(); web->disableKeepAlive = true; String^ deleteUrl = "http://" + selectedSwitch->switch_hostName + "/rest/v1/vlans/" + vlan->vlan_id; web->DELETE(deleteUrl, nullptr); if (web->ErrorLevel == web_client::ErrorStatus::OK) { log->write("VLAN deleted successfully", LogType::Success); logoutSwitch(); return true; } logoutSwitch(); log->write("Error deleting VLAN id: " + vlan->vlan_id + " name: " + vlan->name + ", status: " + Convert::ToString(web->StatusCode), LogType::Error); return false;}
Original Message:
Sent: Sep 19, 2023 05:55 PM
From: Tiffany.Chiapuzio-Wong
Subject: Delete vlan and change vlan name on switch with REST API
@scmalcom also to change the name of a VLAN that already exists you'll want to use the PUT method
------------------------------
Ti Chiapuzio-Wong (they/them)
HPE Aruba Networking
Original Message:
Sent: Sep 19, 2023 10:00 AM
From: scmalcom
Subject: Delete vlan and change vlan name on switch with REST API
Hi all!
I'm trying to use the REST API to delete a VLAN on a HP aruba switch.
but when I try to delete a vlan I get HTTP Error 405 – Method Not Allowed
I tried like this DELETE.../vlans/{Vlan.vlan_id} eg. DELETE restApi/rest/v1/vlans/4
Do anyone know what is the correct way?
And does anyone know if it's possible to change the name of a vlan with REST API?
I can retrieve vlans with http://restApi/rest/v1/vlans
Retrive vlans-ports with http://rest/v1/vlans-ports
Assign port to vlan:
String^ payLoad = "{\"vlan_id\":" + device->vlanInfo->vlan_id + ",\"port_id\":" + "\"" + device->connected_port + "\"" + ",\"port_mode\":" + "\"" + portMode + "\"" + "}";
web->POST(vlanPortsPath, payLoad);
Thanks!