Forum

API call returns HT...
 
Notifications
Retirer tout

API call returns HTML content instead of data

7 Posts
2 Utilisateurs
0 Reactions
3,039 Vu
(@mazama)
Posts: 11
Eminent Member
Début du sujet
 
[#9329]

Hello,

I followed the documentation to get the API running, but an example call returns an HTML page instead of the expected data.

My PHP code is

<?php 
$fullUrl = "http://localhost:3000/api/Ticket/list/all";
$username = "my_username";
$password = "my_password";
 $curl = curl_init($fullUrl);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$curl_response = curl_exec($curl);
 echo $curl_response;
curl_close($curl); 
?> 

And the answer from ProjeQtOr is

 
 

 

 
 
 
 
   
 
 
    ProjeQtOr
 
 
  var isNewGui=true;
  dojo.addOnLoad(function(){
          changeTheme('ProjeQtOrFlatGrey ProjeQtOrNewGui');
            setColorTheming('#3e5876','#ef4227');
            });
    function autoRedirect() {
      window.setTimeout("document.getElementById('indexForm').submit()",10);
    }
 

 

   
 

 

   

   

   

     

   

 

       

                                                           

                            

                           

                                     

           

         

         

           

         

       

                              

                                

                                       

                                

                              

                            

                               

                                 

                                       
                                 

                               

           

             

               
                 
                 
                 
                  (function() {
                    dojo.byId('currentWidth').value= screen.width;
                    })();
                 
               
             

           

       

     

Thanks already for the support.


 
Posté : 20/02/2024 1:09 pm
(@babynus)
Posts: 14952
Membre Admin
 

It seems the .htAccess is not applied as defined in the api folder.
Note that if you use NGINX, you'll have to add the features in the virtualhost


 
Posté : 20/02/2024 6:39 pm
(@mazama)
Posts: 11
Eminent Member
Début du sujet
 

I copied the .htaccess file from the api folder to /var/www/projeqtor. Its content is

  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?uri=$1

AuthUserFile "./.htpasswd"
AuthName "ProjeQtOr"
AuthType Basic
require valid-user 

Here are the error logs from Apache when the requests is performed, I'm not too sure wht it means :

[Thu Feb 22 10:10:46.486813 2024] [authz_core:debug] [pid 366] mod_authz_core.c(815): [client 127.0.0.1:38352] AH01626: authorization result of Require valid-user : denied (no authenticated user yet)
[Thu Feb 22 10:10:46.486835 2024] [authz_core:debug] [pid 366] mod_authz_core.c(815): [client 127.0.0.1:38352] AH01626: authorization result of : denied (no authenticated user yet)
[Thu Feb 22 10:10:46.486949 2024] [authz_core:debug] [pid 366] mod_authz_core.c(815): [client 127.0.0.1:38352] AH01626: authorization result of Require valid-user : granted
[Thu Feb 22 10:10:46.486950 2024] [authz_core:debug] [pid 366] mod_authz_core.c(815): [client 127.0.0.1:38352] AH01626: authorization result of : granted
[Thu Feb 22 10:10:46.487001 2024] [authz_core:debug] [pid 366] mod_authz_core.c(815): [client 127.0.0.1:38352] AH01626: authorization result of Require valid-user : denied (no authenticated user yet)
[Thu Feb 22 10:10:46.487003 2024] [authz_core:debug] [pid 366] mod_authz_core.c(815): [client 127.0.0.1:38352] AH01626: authorization result of : denied (no authenticated user yet)
[Thu Feb 22 10:10:46.487108 2024] [authz_core:debug] [pid 366] mod_authz_core.c(815): [client 127.0.0.1:38352] AH01626: authorization result of Require valid-user : granted
[Thu Feb 22 10:10:46.487109 2024] [authz_core:debug] [pid 366] mod_authz_core.c(815): [client 127.0.0.1:38352] AH01626: authorization result of : granted


 
Posté : 22/02/2024 12:15 pm
(@babynus)
Posts: 14952
Membre Admin
 

When you call the API, you must provide a valid user account (with basic authent) as provided in .htPasswd file.


 
Posté : 22/02/2024 12:27 pm
(@mazama)
Posts: 11
Eminent Member
Début du sujet
 

Yes, the username and password were defined in the .htpasswd using the htpasswd command and they match an admin user defined in ProjeQtor.


 
Posté : 22/02/2024 12:30 pm
(@babynus)
Posts: 14952
Membre Admin
 

Possible, 
but you have to provide this on the API call.


 
Posté : 22/02/2024 1:13 pm
(@mazama)
Posts: 11
Eminent Member
Début du sujet
 

Isn't this done in the PHP code ? I pasted it in my first message.


 
Posté : 22/02/2024 1:26 pm
Share:
Retour en haut