04-26-2022 05:07 AM
Hi Experts,
I had a long weekend, so thought I'd have a shot at checking out the HyperFlex API - the scant documentation and this early video does make it look pretty cool and easy to use, but alas I had no luck in getting it to work.
So I'm hoping someone will tell me why following the documentation doesn't work, and what secret undocumented step I'm missing.
SO here's the thing.
If i access, say https://<hx.ip.address>/restexplorer/#!/Datastore/getDatastores and click the Try it out! button, a little pop-up appears where I put in the username and password.
However, this is a waste of time! It does NOT matter whether I enter the correct password or not, or whether I use the admin user or a user defined in vCenter - the result is ALWAYS the same 401 - Access token invalid
BUT - the curious thing is, it DOES give me a nice curl command line that I can get to work by adding the username and password at the end. And a -k parameter to avoid the certificate error. And I did have to put my password inside single quotes.
admin:~$ curl -X GET --header 'Accept: application/json' 'https://hx.hx.hl.dns/rest/datastores' -u admin:'!@34QWer!@' -k
[{"entityRef":{"id":"00000000e4ee10d4:000000000001019b","type":"DATASTORE","name":"DS1","confignum":0,"setName":true,"setIdtype":false,"setConfignum":false,"setId":true,"setType":true},"stPlatDatastore":{"entityRef":{"id":"00000000e4ee10d4:000000000001019b","type":"DATASTORE","name":"DS1","confignum":
<snip>
So I began thinking about that -k option that I needed to make CURL work. And tried plan "B" - check out the AAA APIs.
https://hx.hx.hl.dns/aaa/restexplorer/index.html#!/Obtain32Access32Token/obtainAccessToken
In this scenario - the password is embodied in the request rather than having to enter the username and password in a pop-up. AND IT WORKED! 201 - success
So can anyone tell me why why entering a password in the body of a request works, but NOT when entering it via a pop-up?
But back to my quest. Now that I have an access_token retuned by this API, I expected I'd be able to USE that token in other requests, like querying the datastores again - only this time adding the token as part of the request rather than relying on the pop-up, as explained in this tutorial on DevNet.
And all I got was MORE disappointment.
Sometimes I get the feeling that I'm simply documenting Cisco bugs (that no-one really cares about anyway - no bug-bounty scheme at Cisco....), but in this case I suspect it is a case of user error (i.e. ME) and one of you wonderful souls out there is going to tell me what I'm doing wrong.
TIA
06-16-2023 07:03 AM
Hello yes i was able to use the token.
Format:
Bearer [And your Token!
Good luck!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide