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
Moderator
Registered: 2007-08-22
Posts: 734

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: 6,146

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...
GLPI10.0.10 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6

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
Moderator
Registered: 2007-08-22
Posts: 734

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
Moderator
Registered: 2007-08-22
Posts: 734

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: 6,146

Re: API usage not possible

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


Trouver la panne avant de réparer...
GLPI10.0.10 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6

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: 6,146

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...
GLPI10.0.10 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6

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

#15 2022-12-16 20:27:11

fneto
Member
Registered: 2013-11-06
Posts: 6

Re: API usage not possible

I'm facing the sane issue with GLPI 10.05, do you have any fix for this problem?

Offline

#16 2022-12-20 13:16:46

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,335
Website

Re: API usage not possible

Please open a new topic with details about what you are trying.


GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.

Offline

#17 2022-12-20 14:41:55

fneto
Member
Registered: 2013-11-06
Posts: 6

Re: API usage not possible

Offline

Board footer

Powered by FluxBB