You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2019-01-21 19:35:42

olegbrendel.
Member
Registered: 2019-01-21
Posts: 10

API usage not possible

HI,

following up on that one:
https : // github . com/glpi-project/glpi/issues/5282

We run with httpS and have self signed certificate but all the documentation always uses http in the API

Is it even possible to use the API with httpS with self signed cert?

What you said on Github that URL is wrong..we have double checked it several times..

Offline

#2 2019-01-22 10:32:16

Jean-Christophe
Guest
Registered: 2007-08-22
Posts: 168

Re: API usage not possible

Could you please elaborate?
I use the API via HTTPS without any problem.

The self signed certificate is not a problem as soon as it is trusted. This has to be managed in your operating system. Nothing to do with the API.

Offline

#3 2019-01-22 11:25:37

olegbrendel.
Member
Registered: 2019-01-21
Posts: 10

Re: API usage not possible

I am trying to run the examples from the beginning of Github API rest documentation of GLPI

And I cannot get back the session_token

- there are two remote access keys in my GLPI personal settings "Personal token" and "API token". I tried with both and it does not work
- I tried with restriction IP range and App_Token and without that, no success


This is what I get in return using the curl command


<!DOCTYPE html>
<html lang="en" class='loginpage'><head><title>GLPI - Authentication</title>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" type="images/x-icon" href="/pics/favicon.ico" /><meta name='viewport' content='width=device-width, initial-scale=1'/><link rel="stylesheet" href="/css/styles.css" type="text/css" media="screen" /><link rel="stylesheet" type="text/css" href="/css/palettes/auror.min.css?v=9.3.1" media="all"><link rel="stylesheet" type="text/css" href="/lib/font-awesome-4.7.0/css/font-awesome.min.css?v=9.3.1" media="all"><script type="text/javascript" src="/lib/jquery/js/jquery-1.10.2.min.js?v=9.3.1"></script><script type="text/javascript" src="/lib/jqueryplugins/select2/js/select2.full.js?v=9.3.1"></script><link rel="stylesheet" type="text/css" href="/lib/jqueryplugins/select2/css/select2.min.css?v=9.3.1" media="all"><script type="text/javascript" src="/js/common.min.js?v=9.3.1"></script></head><body><div id='firstboxlogin'><div id='logo_login'></div><div id='text-login'></div><div id='boxlogin'><form action='/front/login.php' method='post'><p class="login_input" id="login_input_name">
         <input type="text" name="fielda5c46e0b8125ea" id="login_name" required="required"
                placeholder="Login" autofocus="autofocus" />
         </p><p class="login_input" id="login_input_password">
         <input type="password" name="fieldb5c46e0b8125ee" id="login_password" required="required"
                placeholder="Password"  />
         </p><p class="login_input" id="login_input_src"><select name='auth' id='dropdown_auth1' size='1'><option value='local' selected>GLPI internal database</option><option value='mail-1'>Movinga Helpdesk</option></select><script type="text/javascript">
//<![CDATA[

$('#dropdown_auth1').select2({
.....

Offline

#4 2019-01-22 11:51:34

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 4,347

Re: API usage not possible

HI,
glpiversion ?

is API enabled ( setup>general>general setup>api (tab) ?

are you Calling   myserver/glpi/apirest.php ? ( it looks like curl returns glpi login page and not apirest.php)


Trouver la panne avant de réparer...
*GLPI 9.1.6+fusion9.1+1.1+behaviours1.5.0+reports+fields+appliances+pdf+badges+formcreator2.5.2 PHP7.0 Mariadb10
*GLPI 9.2.4(behaviours1.5.2+fusion9.2+1.0+applicatifs2.3.0+dashboard 0.8.9)hebergé sur serveur mutualisé.
*GLPI 9.4.0  en test (ubuntu 18.04 mariadb 10.2.4)

Offline

#5 2019-01-22 12:31:41

olegbrendel.
Member
Registered: 2019-01-21
Posts: 10

Re: API usage not possible

//Version
GLPI 9.3.1

//is API enabled ( setup>general>general setup>api (tab) ?
Yes, Enable Rest API is set to Yes

//are you Calling   myserver/glpi/apirest.php ? ( it looks like curl returns glpi login page and not apirest.php)

I was calling myserver/apirest.php <--like it says in the documentation

Now I tried myserver/glpi/apirest.php <-- and changed it also in the settings before trying

But I get the same response.

May it be that the file does not exist on the server itself?

Offline

#6 2019-01-22 13:59:27

Jean-Christophe
Guest
Registered: 2007-08-22
Posts: 168

Re: API usage not possible

do you have any reverse proxy between you and your server?
do you have any specific virtual host defined at your web server level?
when you try to access the apirest.php from your client computer, you should get the API Help page. Does it work?

Offline

#7 2019-01-22 14:19:34

olegbrendel.
Member
Registered: 2019-01-21
Posts: 10

Re: API usage not possible

Thanks for the tips. Will check this with my team, right now my answer would be: no proxy, no virtual host

When accessing from my computer

https://myserver/glpi/apirest.php/ gives me a blank white web page and in Chrome webtools I see it returns http 302 (found)

https://myserver/apirest.php/ is redirecting me to the homepage of my GLPI https://myserver/front/central.php

Offline

#8 2019-01-22 14:24:38

Jean-Christophe
Guest
Registered: 2007-08-22
Posts: 168

Re: API usage not possible

Do you access the glpi home page via https://myserver/glpi or https://myserver ?
When you browse the home page of glpi, juste add /apirest.php and it should work.

I do not remember having to do anything special for it to work (enable it in settings, of course) :-/

Offline

#9 2019-01-22 15:09:43

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 4,347

Re: API usage not possible

check setup>general>system if some extensions are missing (ie  curl)


Trouver la panne avant de réparer...
*GLPI 9.1.6+fusion9.1+1.1+behaviours1.5.0+reports+fields+appliances+pdf+badges+formcreator2.5.2 PHP7.0 Mariadb10
*GLPI 9.2.4(behaviours1.5.2+fusion9.2+1.0+applicatifs2.3.0+dashboard 0.8.9)hebergé sur serveur mutualisé.
*GLPI 9.4.0  en test (ubuntu 18.04 mariadb 10.2.4)

Offline

#10 2019-01-22 15:17:27

olegbrendel.
Member
Registered: 2019-01-21
Posts: 10

Re: API usage not possible

Yes there are many including curl installed


I think it is something with auth because I am getting the same response when I just curl this root site

curl --insecure https://myserver/


I am getting this sam auth page back in terminal..

will try some more.. thank you for quick support

Offline

#11 2019-01-22 15:24:27

olegbrendel.
Member
Registered: 2019-01-21
Posts: 10

Re: API usage not possible

Can you just tell which of the personal user token is to be used?

"Personal token" or "API token" from my own personal settings

Offline

#12 2019-01-22 15:32:20

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 4,347

Re: API usage not possible

you Don't need token to test if api is working ( go to myserver\glpi\apirest.php)


if you want to login using token  :  use API token for user and  Application token (app_token) from setup>general>api>api clients => then you should get session token


Trouver la panne avant de réparer...
*GLPI 9.1.6+fusion9.1+1.1+behaviours1.5.0+reports+fields+appliances+pdf+badges+formcreator2.5.2 PHP7.0 Mariadb10
*GLPI 9.2.4(behaviours1.5.2+fusion9.2+1.0+applicatifs2.3.0+dashboard 0.8.9)hebergé sur serveur mutualisé.
*GLPI 9.4.0  en test (ubuntu 18.04 mariadb 10.2.4)

Offline

#13 2019-01-22 16:01:57

olegbrendel.
Member
Registered: 2019-01-21
Posts: 10

Re: API usage not possible

I think I call the API in a good way now

but

<p>You must activate the JavaScript function of your browser</p>

Is part of the response in Postman and Terminal (Curl)

Without really knowing what the code does it looks to me that it tries to retrieve or calculate my session token and at some point it returns me to enable JS

???!

Offline

#14 2019-01-28 11:51:59

olegbrendel.
Member
Registered: 2019-01-21
Posts: 10

Re: API usage not possible

still having trouble with the API
it always returns our servers GLPI loginpage - no matter what I try with Authorization

any help pls?

Offline

Board footer

Powered by FluxBB