Wired Intelligent Edge (Campus Switching and Routing)

New Contributor

Trouble getting started with REST API

Hi all,


I'm trying to get started with network automation, and I'm having some issues figuring out how to use the REST API.


I've been using Postman to try to interrogate the API (i'm trying to pull VLANs with x.x.x.x/rest/v1/vlans, but every time I try to do a GET request, I get 400 bad request, the REST session timed out. Please try again.


Could this be because the switch requires a username and password?


Does anyone have any suggestions that could help me out?

Aruba Employee

Re: Trouble getting started with REST API

Can you make sure, below points are taken cared before accessing vlans?

1. REST API enabled on switch (show rest-interface).

2. REST API login to switch is successful and cookie is returned. ( you can check this thread on how to parse the credentials in Postman. http://community.arubanetworks.com/t5/Campus-Switching-and-Routing/2930M-16-04-Unable-to-Login-via-REST-API/m-p/404685 )

Login URL --> x.x.x.x/rest/v3/login-sessions

body, select 'raw' and give the JSON --> 

{"userName" : "switchusername","password" : "password"}


Once this is successful, GET command for vlans should work. 

URL what you mentioned looks good ( x.x.x.x/rest/v1/vlans)


You can also download detailed documention for switch REST API from https://support.hpe.com (attached here)


Also, try out sample python code for ArubaOS-Switch REST API  workflows at https://github.com/aruba/arubaos-switch-api-python 


Aruba Employee

Re: Trouble getting started with REST API



Can you tell which switch you are trying to access? What's the config of the switch?


Kind regards,



New Contributor

Re: Trouble getting started with REST API

Hello, I am a student employee at a university serviced by Aruba, and am working on using your software aruba-switch-ansible to automate our network.  I also tried using aruba-ansible modules, but switched after I couldn't get it to work. I am working on a test switch, a 2930M.  After aruba-switch-ansible and aruba-ansible-modules had the same problem, I realized that it is probably an issue with a switch setting, not something with the software.  The problem that I encountered with both softwares was that it could not navigate to https://x.x.x.x/rest/v4/login-sessions, and I did try different version numbers.  Whenver I try to access it via this web browser, I get the same error as the guy who posted the original thread, 400: Bad Request.  When I navigate to the switch via https://x.x.x.x , it directs me to an html page: https://x.x.x.x/html/banner.html and after clicking 'continue' on the webpage it directs me to https://x.x.x.x/html/login.html.  The first command I have been trying to execute is a POST login command, the one in aruba-switch-ansible playbook, arubaoss_tasks_config_example.


I believe the problem may have to do with my SSL interactions or my web-management settings.  In the CLI, I see several things that led me to this conclusion:

1) I get that the SSL port is already in use:

SW-NAME-01(config)# web-management ssl
web-management: The specified TCP/UDP port is in use by another protocol.


2) The management URL is still the default management URL, I didn't know if this needed to be changed to the https://x.x.x.x/rest/v4/login-sessions or how to change it, if this is the problem: 

SW-NAME-01(config)# show web-management

Web Management - Server Configuration

HTTP Access : Enabled
HTTPS Access : Enabled
SSL Port : 443
Idle Timeout : 600 seconds
Management URL : http://h17007.www1.hpe.com/device_help
Support URL : https://www.hpe.com/us/en/networking.html
User Interface : Improved
Listen Mode : both


My REST interface settings appear to all be correct based on the Aruba documentation I have seen:

SW-NAME-01# show rest-interface

REST Interface - Server Configuration

REST Interface : Enabled
REST Operational Status : Up
REST Session Idle Timeout : 600 seconds
HTTP Access : Enabled
HTTPS Access : Enabled
SSL Port : 443


I have already tried a few solutions, like switching the body_format in login_switch.yml in aruba-switch-ansible to raw, and form-urlencoded from its default json.  This caused status 200 and status -1 errors, but neither could login to the switch.  I also tried setting it to raw, and making the text objects that I'm looking for, so that they match those on the page.  Eg. "password" to how it was on the page, "Password:".  The last thing I tried was just changing the url to https://x.x.x.x/html/login.html, but this also did not work.


I had pretty much the exact same problem with aruba-ansible-modules and could also not figure out how to fix it there.  Any support would be appreciated, thank you.


New Contributor

Re: Trouble getting started with REST API

also, using Aruba switch software version WC.16.07.0005.  I can update it to the newest version if you think that may be the problem.

MVP Expert

Re: Trouble getting started with REST API

do you have fix your issue ?


it is better to use last release for API Stuff

PowerArubaSW: Powershell Module to use Aruba Switch API for Vlan, VlanPorts, LACP, LLDP... More info

PowerArubaCP: Powershell Module to use ClearPass API (create NAD, Guest...) More info

PowerArubaCX: Powershell Module to use ArubaCX API (get interface/vlan/ports info)

PowerArubaIAP: Powershell Module to use Aruba Instant AP

ACMP 6.4 / ACMX #107 / ACCP 6.5
New Contributor

Re: Trouble getting started with REST API

Yes, I was able to solve the issue, and the problem was not something posted here before.  I had to change the web interface URL in our Enterprise Network, Configuration Manager (Solarwinds Orion) from the default, http://x.x.x.x to https://x.x.x.x/rest/v3 (or whatever rest version).  With that, it now can interact with the REST features on the switch.

Search Airheads
Showing results for 
Search instead for 
Did you mean: