I have a new 7.10 installed on a Plesk / CentOs server using Apache.
The SuiteCRM site itself seems to run without problems but I am having issues accessing the APIs as documented here:
http://docs.suitecrm.com/developer/api/api-8/
A GET on /api/v8/swagger.json returns ‘No input file selected’.
If I navigate using the full path URL:
https://[my domain]/lib/API/v8/swagger.json
The swagger file is displayed which makes me think there’s an issue with the .htaccess file that maps the /api entrypoint to the lib/API/public folder.
Looking at the .htaccess this line looks incorrect:
RewriteRule ^api/(.*?)$ lib/SuiteCRM/API/public/index.php/$1 [L]
For it to work I think it should look like this:
RewriteRule ^api/(.*?)$ lib/API/public/index.php/$1 [L]
However even with this change the same error is returned.
Any help appreciated
Matt
pgr
24 February 2018 16:10
2
Hi, welcome.
Can you please check your web server logs for errors?
error_log
access_log
php_errors.log
Here are the log entries:
access_ssl_log:
[25/Feb/2018:10:52:02 +0000] “GET /api/v8/swagger.json HTTP/1.0” 404 1474 “-” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36”
error_log:
[error] [client 90.255.220.109] File does not exist: /var/www/vhosts/[mydomain].com/subdomains/crm.[mydomain].com/SuiteCRM/lib/SuiteCRM
The install directory is this:
/var/www/vhosts/[mydomain].com/subdomains/crm.[mydomain].com/SuiteCRM
from there the relevant directory structure is:
lib/API/v8
However the .htaccess file is assuming a directory structure of lib/SuiteCRM /API:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^cache/jsLanguage/(.._..).js$ index.php?entryPoint=jslang&modulename=app_strings&lang=$1 [L,QSA]
RewriteRule ^cache/jsLanguage/(\w*)/(.._..).js$ index.php?entryPoint=jslang&modulename=$1&lang=$2 [L,QSA]
RewriteRule ^api/(.*?)$ lib/SuiteCRM/API/public/index.php/$1 [L]
RewriteRule ^api/(.*)$ - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Grepping for API in the code the assumed structure also seems to be the same:
$container['ResourceServer'] = function () {
$keys = new \SuiteCRM\API\OAuth2\Keys();
$server = new \League\OAuth2\Server\ResourceServer(
new SuiteCRM\API\OAuth2\Repositories\AccessTokenRepository(),
$keys->getPublicKey()
);
return new \[b]SuiteCRM[/b]\API\OAuth2\Middleware\ResourceServer($server);
};
I can navigate to the swagger file if I specify the absolute path:
https://crm .[mydomai].com/lib/API/v8/swagger.json
Note the upper case API
Is the .htaccess incorrect or is the directory incorrect (as in it should be lib/SuiteCRM)?
Any help appreciated - I’m new to SuiteCRM and I’ve spun on this for a while now.
Thanks
Matt
pgr
25 February 2018 11:35
4
I just found this bug that’s has somethinng to do with prepending vs appending htaccess file changes during the upgrade
https://github.com/salesagility/SuiteCRM/pull/5225
Maybe that will help you figure out a solution…
I ran a fresh install of the last 7.10 zip rather than an upgrade.
I’ll keep on digging…
pgr
25 February 2018 12:03
6
Hopefully on Monday one of the developers involved in that issue will take a look at this thread and help you out.
If I modify the .htaccess file so that this line is included:
ReWriteRule ^api/(.*)$ lib/API/$1 [L]
I can then successfully see the swagger document when I navigate to:
https://[mydomain]/api/v8/swagger.json
The problem looks like it is related to the .htaccess file as far as I can tell.
pgr
27 February 2018 17:02
8
Have you tried Admin / Repair / Rebuild htaccess file?
Or better: apply the fix in that PR I linked above, and then do that Repair.
Thanks for the suggestions.
I downloaded and installed the latest zip which looks like it included the modification in the fix.
Running the htaccess rebuild fixed the path problem in that
RewriteRule ^api/(.*?)$ lib/API/public/index.php/$1 [L]
is no longer
/lib/SuiteCRM/API
but accessing the swagger file still results in the same No input file specified result.
Adding:
ReWriteRule ^api/(.*)$ lib/API/$1 [L]
to .htaccess results in the swagger file rendering which I think suggests the issue is .htaccess related.
I guess there needs to be a change to the formal rewrite rules:
RewriteRule ^api/(.?)$ lib/API/public/index.php/$1 [L]
RewriteRule ^api/(. )$ - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
Not sure what that should be though.
Matt
Hi Matt,
Please add this to the top of your .htaccess file:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase path-to-instance
RewriteRule ^cache/jsLanguage/(.._..).js$ index.php?entryPoint=jslang&modulename=app_strings&lang=$1 [L,QSA]
RewriteRule ^cache/jsLanguage/(\w*)/(.._..).js$ index.php?entryPoint=jslang&modulename=$1&lang=$2 [L,QSA]
RewriteRule ^cache/jsLanguage/(.._..).js$ index.php?entryPoint=jslang&module=app_strings&lang=$1 [L,QSA]
RewriteRule ^cache/jsLanguage/(\w*)/(.._..).js$ index.php?entryPoint=jslang&module=$1&lang=$2 [L,QSA]
RewriteRule ^api/(.*?)$ lib/API/public/index.php/$1 [L]
RewriteRule ^api/(.*)$ - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Please change the base url accordinly, eg / if suitecrm is configured at the base of the file structure. You can use the rebuild .htaccess tool in suitecrm if you are not sure.
Please check that you have configured apache2 so that modrewrite is enabled, and that you allow your www directory to override the configuration.
Example - 000-default.config
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Can you try to authenticate with the oauth 2 server? what is the response you are getting?
1 Like
Thanks for the help - unfortunately I still get the same issue:
My .htaccess looks like this:
# BEGIN SUGARCRM RESTRICTIONS
RedirectMatch 403 .*\.log$
RedirectMatch 403 /+not_imported_.*\.txt
RedirectMatch 403 /+(soap|cache|xtemplate|data|examples|include|log4php|metadata|modules)/+.*\.(php|tpl)
RedirectMatch 403 /+emailmandelivery\.php
RedirectMatch 403 /+upload
RedirectMatch 403 /+cache/+diagnostic
RedirectMatch 403 /+files\.md5$
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^cache/jsLanguage/(.._..).js$ index.php?entryPoint=jslang&modulename=app_strings&lang=$1 [L,QSA]
RewriteRule ^cache/jsLanguage/(\w*)/(.._..).js$ index.php?entryPoint=jslang&modulename=$1&lang=$2 [L,QSA]
RewriteRule ^cache/jsLanguage/(.._..).js$ index.php?entryPoint=jslang&module=app_strings&lang=$1 [L,QSA]
RewriteRule ^cache/jsLanguage/(\w*)/(.._..).js$ index.php?entryPoint=jslang&module=$1&lang=$2 [L,QSA]
RewriteRule ^api/(.*?)$ lib/API/public/index.php/$1 [L]
RewriteRule ^api/(.*)$ - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
# END SUGARCRM RESTRICTIONS
If I modify the rewrite rule by adding a ?
RewriteRule ^api/(.*?)$ lib/API/public/index.php[b]?[/b]/$1 [L]
I get this, which suggests that the mod rewrite is active:
{"error":"access_denied","message":"The resource owner or authorization server denied the request.","hint":"Missing \"Authorization\" header"}
I’m new to Suite CRM - how do I authenticate with the OAuth server? Is there a tutorial anywhere?
Thanks
Matt
Hi Matt,
It should be:
RewriteRule ^api/(.*?)$ lib/API/public/index.php/$1 [L]
RewriteRule ^api/(.*)$ - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
If you have added my suggested fix and are getting any kind of a response from the OAuth2 server (including access_denied), the it means that you have correctly set up the .htaccess file and mod rewrite.
If you can’t still access the swagger file, then It sound’s like this is an issue with the swagger.json route itself, instead of the .htaccess.
The documentation for how to authenticate and work with the API is here:
https://docs.suitecrm.com/developer/api/api-8/
Please note: You need to set up a client first before you authenticate with the API. See the documentation link for details.
niot29
19 November 2018 11:45
14
I Have the same problem. Have install version 7.10.10 and cant get to swagger.json filen.
The requested URL /suitecrm7_10/lib/API/public/index.php/v8/swagger.json was not found on this server.
Have U found any solutionen. …?
httpd log access.log:
[19/Nov/2018:12:44:33 +0100] “GET /suitecrm7_10/api/v8/swagger.json HTTP/1.1” 404 251 “-” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36”
Same version (7.10.10) same problem. Seems that lib/API/public folder is missing!!!
I’m in the same boat. I’m working on implementing the V8 api and don’t appear to have the lib/API/public folder. Just to confirm that it wasn’t just my install, I downloaded version 7.10.10 from the suite crm website and it’s missing the public folder as well. Any help would be greatly appreciated. This is the contents of my htaccess file
# BEGIN SUGARCRM RESTRICTIONS
RedirectMatch 403 (?i).*\.log$
RedirectMatch 403 (?i)/+not_imported_.*\.txt
RedirectMatch 403 (?i)/+(soap|cache|xtemplate|data|examples|include|log4php|metadata|modules)/+.*\.(php|tpl)
RedirectMatch 403 (?i)/+emailmandelivery\.php
RedirectMatch 403 (?i)/+upload
RedirectMatch 403 (?i)/+cache/+diagnostic
RedirectMatch 403 (?i)/+files\.md5$
<IfModule mod_rewrite.c>
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /admin
RewriteRule ^cache/jsLanguage/(.._..).js$ index.php?entryPoint=jslang&modulename=app_strings&lang=$1 [L,QSA]
RewriteRule ^cache/jsLanguage/(\w*)/(.._..).js$ index.php?entryPoint=jslang&modulename=$1&lang=$2 [L,QSA]
RewriteRule ^cache/jsLanguage/(.._..).js$ index.php?entryPoint=jslang&module=app_strings&lang=$1 [L,QSA]
RewriteRule ^cache/jsLanguage/(\w*)/(.._..).js$ index.php?entryPoint=jslang&module=$1&lang=$2 [L,QSA]
# --------- DEPRECATED --------
RewriteRule ^api/(.*?)$ lib/API/public/index.php/$1 [L]
RewriteRule ^api/(.*)$ - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# -----------------------------
RewriteRule ^Api/access_token$ Api/index.php/access_token [L]
RewriteRule ^Api/V8/(.*?)$ Api/index.php/V8/$1 [L]
RewriteRule ^Api/(.*)$ - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
# END SUGARCRM RESTRICTIONS
chad1
2 January 2019 17:19
17
Same issue 7.10.11 … no lib/API/public folder