1

When using Webservices on my local development environment, but the problem is not unique to local environments, I received the following message for even the core features,

The requested URL was not found on this server.

The same request, http://my.domain/api/v1/content/articles, to other instances worked fine.

One of the symptoms, if you have a Debugger switched on, is that no API calls triggers any execution of the webservice plugins, which is different to if you have provided an endpoint that doesn't exist, eg. /v1/api/content/fred

It comes down to the environment being slightly different and hopefully the answer will help.

1 Answer 1

1

Depending on which tutorial, samples of a request or Postman collection you are using there are two versions for an end point used, note the index.php is not used in the first as was the case in my issue.

http://my.domain/api/v1/content/articles

and

http://my.domain/api/index.php/v1/content/articles

The variation with the index.php will always work, however it looks odd and I don't believe an API endpoint should have that in its request, while without the index.php you will need to have these lines that appear in the default htaccess.txt available in your .htaccess .

# -- SEF URLs for the API application
# If the requested path starts with /api, the file is not /api/index.php
# and the request has not already been internally rewritten to the
# api/index.php script
RewriteCond %{REQUEST_URI} ^/api/
RewriteCond %{REQUEST_URI} !^/api/index\.php

Note Rewrite ON is required prior to this.

After I found the cause and knew what to search for, I did find this previous post on JSE that addresses the same issue, Website not correctly displaying "Not Found - The requested URL was not found on this server." , the suggested solution requires you to turn on SEF to get the URL rewrite option which in turn requires you to have a .htaccess file. For my purposes I have SEF turned off.

The solution is simpler, you need to have a .htaccess, the default Joomla one is enough, with the above lines if you want to exclude the index.php from your requests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.