XF 2.2 API problem

Casa Ivar

Member
Hi all,

We are having problems connecting to the API on my forum. Doing some troubleshooting, I see that this URL:
..in this Xenforo installation gives an API error.

{
"errors": [
{
"code": "no_api_key_in_request",
"message": "No API key was included in the request.",
"params": []
}
]
}

But on my forum, what happens is if I go to that same URL, it forwards me to:
myforum/community/api/install/index.php
....with an error message in the browser "File not found".

On the other hand, if I go to:
Myforum/community/api/threads/
...I get an API response.

{
"errors": [
{
"code": "no_api_key_in_request",
"message": "No API key was included in the request.",
"params": []
}
]
}

Does anyone have an idea of what might be going on?

Does the "File not found" error means I am missing files? The file check on the forum is coming back "all good".

Thank you!
Ivar
 

Brogan

XenForo moderator
Staff member
The file not found message is because there is no file at /api/install/index.php .

The issue is that it appears a server side rewrite is rewriting visits to /api to /api/install/index.php .

Check .htaccess if on Apache or the conf file if on nginx.
 

Casa Ivar

Member
Hi again,

This is still a mystery... we have since my last posts and created a clone of the installation in a testing environment without the reverse proxy and without Nginx. So we are now only using apache/.htaccess.

Here is the .htaccess file:

# Mod_security can interfere with uploading of content such as attachments. If you
# cannot attach files, remove the "#" from the lines below.
#<IfModule mod_security.c>
# SecFilterEngine Off
# SecFilterScanPOST Off
#</IfModule>

ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default

<IfModule mod_rewrite.c>
RewriteEngine On

# If you are having problems with the rewrite rules, remove the "#" from the
# line that begins "RewriteBase" below. You will also have to change the path
# of the rewrite to reflect the path to your XenForo installation.
#RewriteBase /xenforo

# This line may be needed to enable WebDAV editing with PHP as a CGI.
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>

Now when I go to:


..it redirects to:


...with a response from the API:
{
"errors": [
{
"code": "no_api_key_in_request",
"message": "No API key was included in the request.",
"params": []
}
]
}

But it still redirects to an install folder!?! Could it be a thing with my installation that has not been completed and it would like to "keep installing"? It all looks good in the admin panel, except for these two items...

Screenshot 2022-11-04 at 12.05.48.png

Ideas?

Thank you!
Ivar
 

Brogan

XenForo moderator
Staff member
Those should be resolved but I don't see how they would be involved.

Are any route filters set up in the ACP?

If not, I'm out of ideas - it must be something server side.
 

Brogan

XenForo moderator
Staff member
It's an interesting one ... well, as interesting as troubleshooting forum stuff goes.

If you want to submit a ticket with ACP and server access for the test installation, we can take a look.
 
Top