Site icon TestingDocs.com

How to fix Slim Application Error in TestLink

Overview

In this tutorial, we will learn the steps involved in fixing Slim Application Error while executing Rest API calls on a TestLink Instance. Many TestLink Rest API errors can be solved if you install the Slim framework on your Testlink instance.

https://www.testingdocs.com/install-slim-framework-on-windows/

Error: Slim Application Error

The application could not run because of the following error:

Details

Type: ErrorException
Code: 8
Message: Undefined index: PHP_AUTH_USER
File: /var/www/html/testlink/lib/api/rest/v2/tlRestApi.class.php
Line: 214

Sample Trace

#0 /var/www/html/testlink/lib/api/rest/v2/tlRestApi.class.php(214): 
Slim\Slim::handleErrors()
#1 [internal function]: tlRestApi->authenticate()
#2 /var/www/html/testlink/third_party/Slim/Router.php(168): 
call_user_func_array()
#3 /var/www/html/testlink/third_party/Slim/Slim.php(1222): 
Slim\Router->dispatch()
#4 /var/www/html/testlink/third_party/Slim/Middleware/Flash.php(86):
 Slim\Slim->call()
#5 /var/www/html/testlink/third_party/Slim/Middleware/MethodOverride.php(94):
 Slim\Middleware\Flash->call()
#6 /var/www/html/testlink/third_party/Slim/Middleware/PrettyExceptions.php(67):
 Slim\Middleware\MethodOverride->call()
#7 /var/www/html/testlink/third_party/Slim/Slim.php(1174): 
Slim\Middleware\PrettyExceptions->call()
#8 /var/www/html/testlink/lib/api/rest/v2/index.php(20): Slim\Slim->run()
#9 {main}

 

Screenshot

 

Indication

As the error trace indicates the there is an authentication problem with the rest API request.

tlRestApi->authenticate()

PHP_AUTH_USER

Error in Apache Error Log

Fix

Enable API key on the TestLink instance. ( https://www.testingdocs.com/testlink-api/ )

Pass the APIKEY and its value along with the API request.

This would fix the following error when we send an API request. It’s directly not possible to call the GET request that needs Authorization with a Web browser.  We can leverage API tools like Postman. (https://www.testingdocs.com/postman-api-tool/)

Fix Validation in Postman

Hit the API Endpoint:

http://<testlink_HOME>/lib/api/rest/v2/whoAmI

HTTP method as GET

Pass the APIKEY and its value that was generated in the TestLink web settings in the Authorization tab.

Send the API request.

Expected Result: Should be 200 OK Http Response

Exit mobile version