Live Helper Chat support forum.. Forum is locked. New place for questions - Github Discussions

You are not logged in.

Announcement

#1 2018-02-22 12:37:33

martin08
Member
Registered: 2018-02-22
Posts: 4

Rest API help

Hi all,

I installed most recent version of lhc and generated API keys for 2 users.
Accessing the old 'xml' named api using username/password in body in posts works fine for me.

Accessing REST API however fails for some reason and the sparse documentation did not help me out up to now  cry
Trying in Swagger, i first press authenticate button and provide username and API Key.
Calling any method afterwards fails with undocumented code "TypeError.Failed to fetch"
Code 200 Login
Code 400 Error

curl request was:
curl -X POST "http://192.168.11.129/restapi/login" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d "username=xxx&password=xxx&generate_token=true&device=unknown"

When I try the same in Postman i get at least some more info:
Post on http://192.168.11.129/index.php/restapi/login
Basic Auth with username/password results in
{
    "error": true,
    "msg": "Authentification failed"
}

Basic Auth with username/api key delivers the same result

Any hints are highly appreciated, cause I really have no idea what to try.
Thx
-Martin

Offline

#2 2018-02-22 12:46:27

martin08
Member
Registered: 2018-02-22
Posts: 4

Re: Rest API help

For some very very very weired reason it works in POSTMAN right now.
For anyone strumbling accross this post, here is what i did.
Create a Post to http://<yourIP>/index.php/restapi/login
Set Authorization in Postman to basic and provide username and API key there

Fill Body with all parameters found in Swagger
That is:
password <-- as given by lhc user configuration
username <-- as given by lhc user configuration
generate token <-- true
device <-- unknown worked for me
device_token <-- supply anything there

Then i do get json reply
{
    "error": false,
    "session_token": "3abd4209219b399096019cdac228f483"
}

Weeeehaaaa!
lol

Offline

#3 2018-02-22 13:04:09

PeopleInside
Administrator
From: Italy
Registered: 2014-04-10
Posts: 4,046
Website

Re: Rest API help

cool  Thank you for the updates  smile

Last edited by PeopleInside (2018-02-22 13:04:21)


lol PeopleInside - Live helper chat - free limited forum support!
wink For commercial support or GitHub [see FAQ here]
ops If you want to support this open source project, just donate [see support page]
glasses Something wrong with the forum? [contact a superhero]

Offline

#4 2018-02-22 14:43:18

martin08
Member
Registered: 2018-02-22
Posts: 4

Re: Rest API help

Nevertheless I'm still stuck - I do get an authorization token during login, but for a get request - let's assume getusers
e.g. http://192.168.11.129/index.php/restapi/getusers

I am not forced to pass it via parameter and get doesn't have any body - so what am I lacking here?
Again it's
{
    "error": true,
    "result": "Authorization failed!"
}

Still using basic authentication with username and api key
Any guesses?

Offline

#5 2018-02-22 15:26:41

martin08
Member
Registered: 2018-02-22
Posts: 4

Re: Rest API help

What i would expect to work is passing the AUTH token in header as Bearer Token instead of Basic Auth for successive calls.
I'm beginning to doubt maturity of this REST interface  sad

Offline

#6 2018-02-22 15:50:17

PeopleInside
Administrator
From: Italy
Registered: 2014-04-10
Posts: 4,046
Website

Re: Rest API help

Sorry, I cannot help with that.
I informed the chat owner about this topic.


lol PeopleInside - Live helper chat - free limited forum support!
wink For commercial support or GitHub [see FAQ here]
ops If you want to support this open source project, just donate [see support page]
glasses Something wrong with the forum? [contact a superhero]

Offline

Board footer