1753717 Members
5710 Online
108799 Solutions
New Discussion

Re: REST API -

 
jamesfed
Occasional Contributor

REST API -

Hi all,

Has anyone managed to get the REST API on HPE ProCurve/Aruba switches (for example the 2530 series) working?

When running firmware version YA.16.02.0010 with HTTP/HTTPS web server enabled and the rest-interface feature enabled everytime I try to login to the switch (using the commands provided in this guide - http://h20565.www2.hpe.com/hpsc/doc/public/display?sp4ts.oid=5333803&docLocale=en_US&docId=emr_na-c05068466) I just get timed out error messages. This is on both the HTTP and HTTPS interfaces (and I have installed a valid cert on the HTTPS interface).

Having tried with both curl (as stated in the guide) and the Invoke-RestMethod (in PowerShell) each and everytime its the same - connection times out.

Anyone have any thoughts? Verbose and debug logs don't seem to offer any help either.

James

7 REPLIES 7
parnassus
Honored Contributor

Re: REST API -

Have you tried to modify (with the rest-interface session-idle-timeout <SECONDS> command) the rest-interface session-idle-timeout from default 600 seconds to an higher value?

The admitted range spans from 120 seconds up to 7200 seconds.

Are you using the 16.02 REST API and JSON Schema or the 16.01 one?

Both Release Notes look exactly the same but related downloadable files are differents (verified with a diff): I compared the 16.01 (here) with the 16.02 (here) but I can't attach the txt file with the diff between the two device-rest-api folder structures (16.01 vs 16.02)...it appears that 16.02 has more and modified json files.

"The REST API and JSON Schema zip file contains the JSON Schema and REST API documentation for X.16.02.xxxx software. Extract the .zip file locally. The schema folder contains the JSON files. The services folder contains common and wired subfolders, each with an .html document showing the REST resources and referencing the JSON schema employed by each resource."


I'm not an HPE Employee
Kudos and Accepted Solution banner
richard5
New Member

Re: REST API -

Im a little late to the party but I had lots of issues using the API as well, even in version 16.03.0004. I think theres still some bugs that need to be ironed out. I had luck getting the login to work with curl, but when i tried using powershell I encountered the timeout issue. Strangely, I tried using powershell on OSX (im testing out an alpha version) with exactly the same code and was able to login and perform other requests. What was really interesting was if I used a working session id in (from powershell OSX, curl, postman etc) I was able to perform every other query from powershell without issue. The problem seemed to only be the login request. I ened up using wireshark to have a look at the differences in the packets there was a few differences in headers. Finngers crossed powershell plays nice with the next version, I plan on giving some feedback to HPE/Aruba if theres still issues with the next version. 

ChrisT2
Occasional Visitor

Re: REST API -

Hi Richard5. I have exactly the same issue where I am able to login via cURL command line on my Mac but not in the Chrome Postman App. Frustrating! i've even imported the command line into Postman and it's still saying bad request. I'm also on 16.03. Will post back here if I can sort it

Matthew_R
Frequent Visitor

Re: REST API -

I too have spent too much time getting this to work.  The fact the HP has done nothing to fix this or acknoweldge an issue is even worse.  I have tried curl on mac and pc, powershell, everything I can think of to get logged in and I get "Bad Request.  Please login to access the resource".   When I look at the log on the switch in shows a warning "invalid username/password on the REST session; the user " is trying to login."  That error leads me to believe a problem exists with passing the username.  Frustrating ... 

ChrisT2
Occasional Visitor

Re: REST API -

Hi Matthew. Mine is working fine from curl on the command line so I don't think it's a total lockout. What version of code are you running on the switch?

Matthew_R
Frequent Visitor

Re: REST API -

I was on version 16_03_0003 and I couldnt get it to work, so I updated the firmware to 16_03_0004 this morning and still can't get logged in.  What version of curl are you using?  What does your command line look like?  I read a post about quotes not being the same on curl for windows, but the suggestion they gave didnt work either.  Any suggestions would be greatly appreciated. 

Matthew_R
Frequent Visitor

Re: REST API -

UPDATE  I figured it out the issue I was having and wanted to update the post in the event another person has the same issues.  After doing some digging in the FAQ for curl I discovered three things that really helped:

3.13 Why does my single/double quotes fail?

 

Exactly what kind of quotes and how to do this is entirely up to the shell
or command line interpreter that you are using. For most unix shells, you
can more or less pick either single (') or double (") quotes. For
Windows/DOS prompts I believe you're forced to use double (") quotes.

3.22 curl -X gives me HTTP problems

In normal circumstances, -X should hardly ever be used.

By default you use curl without explicitly saying which request method to
use when the URL identifies a HTTP transfer. If you just pass in a URL like
"curl http://example.com" it will use GET. If you use -d or -F curl will use
POST, -I will cause a HEAD and -T will make it a PUT.

4.2 Why do I get problems when I use & or % in the URL?

In Windows, the standard DOS shell treats the percent sign specially and you
need to use TWO percent signs for each single one you want to use in the
URL.

If you want a literal percent sign to be part of the data you pass in a POST
using -d/--data you must encode it as '%25' (which then also needs the
percent sign doubled on Windows machines).  In this case the special character was in the password.

 

So this is what I ended up with:

curl --noproxy <ipaddress> http://<ipaddress>:80/rest/v1/login-sessions -d "{"""userName""":"""username""","""password""":"""password"""}"

 

Hope others find this helpful.