Skip to main content

Hello everyone,

I am trying to get metric results using rest api request.

I have enabled the rights to reach api configuration for the user.

I get the api token by giving credentials via action authenticate

But when i use the token i get unauthorized access.

Here are the commands used :

 

 

curl -v -d "username=admin&password=centreon" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://172.20.10.2/centreon/api/index.php?action=authenticate

 

 

curl -v http://172.20.10.2/centreon/api/index.php?object=centreon_realtime_services^&action=list -H 'Content-Type:application/json' -H 'X-AUTH-TOKEN:6hwVYFtJerPts6JHopkN1qlZQ0xPo32DIUg2hOyyy220PPvQ3ANBWqiyEl11pxpv'

 

And some screens for the result : 

 

 

syntax error : the problem was using single quotes in the command

changed the command to de following worked :

 

curl -v http://172.20.10.2/centreon/api/index.php?object=centreon_realtime_services^&action=list -H “Content-Type:application/json” -H “X-AUTH-TOKEN:”6hwVYFtJerPts6JHopkN1qlZQ0xPo32DIUg2hOyyy220PPvQ3ANBWqiyEl11pxpv””


Reply