Need help with malfuntioned API v8 on Windows IIS :-(

Hey guys,

I am on the 7.11.18 and after migrating to IIS I have a huge problem with API. Here is the sum up:

  • in IIS we have URL Redirect module installed

  • web.config is this:

      <?xml version="1.0" encoding="UTF-8"?>
      <configuration>
       <system.webServer>
        <rewrite>
         <rules>
          <rule name="HTTP to HTTPS redirect" stopProcessing="true">
              <match url="(.*)" />
              <conditions>
              <add input="{HTTPS}" pattern="off" />
              </conditions>
              <action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
          </rule>
          <rule name="redirect0" stopProcessing="true">
           <match url="suitecrm\.log\.*" />
           <action type="Redirect" url="log_file_restricted.html" redirectType="Found" />
          </rule>
          <rule name="redirect1" stopProcessing="true">
           <match url="install.log" />
           <action type="Redirect" url="log_file_restricted.html" redirectType="Found" />
          </rule>
          <rule name="redirect2" stopProcessing="true">
           <match url="upgradeWizard.log" />
           <action type="Redirect" url="log_file_restricted.html" redirectType="Found" />
          </rule>
          <rule name="redirect3" stopProcessing="true">
           <match url="emailman.log" />
           <action type="Redirect" url="log_file_restricted.html" redirectType="Found" />
          </rule>
          <rule name="redirect4" stopProcessing="true">
           <match url="not_imported_.*.txt" />
           <action type="Redirect" url="log_file_restricted.html" redirectType="Found" />
          </rule>
          <rule name="redirect5" stopProcessing="true">
           <match url="XTemplate/(.*)/(.*).php" />
           <action type="Redirect" url="index.php" redirectType="Found" />
          </rule>
          <rule name="redirect6" stopProcessing="true">
           <match url="data/(.*).php" />
           <action type="Redirect" url="index.php" redirectType="Found" />
          </rule>
          <rule name="redirect7" stopProcessing="true">
           <match url="examples/(.*).php" />
           <action type="Redirect" url="index.php" redirectType="Found" />
          </rule>
          <rule name="redirect8" stopProcessing="true">
           <match url="include/(.*).php" />
           <action type="Redirect" url="index.php" redirectType="Found" />
          </rule>
          <rule name="redirect9" stopProcessing="true">
           <match url="include/(.*)/(.*).php" />
           <action type="Redirect" url="index.php" redirectType="Found" />
          </rule>
          <rule name="redirect10" stopProcessing="true">
           <match url="log4php/(.*).php" />
           <action type="Redirect" url="index.php" redirectType="Found" />
          </rule>
          <rule name="redirect11" stopProcessing="true">
           <match url="log4php/(.*)/(.*)" />
           <action type="Redirect" url="index.php" redirectType="Found" />
          </rule>
          <rule name="redirect12" stopProcessing="true">
           <match url="metadata/(.*)/(.*).php" />
           <action type="Redirect" url="index.php" redirectType="Found" />
          </rule>
          <rule name="redirect13" stopProcessing="true">
           <match url="modules/(.*)/(.*).php" />
           <action type="Redirect" url="index.php" redirectType="Found" />
          </rule>
          <rule name="redirect14" stopProcessing="true">
           <match url="soap/(.*).php" />
           <action type="Redirect" url="index.php" redirectType="Found" />
          </rule>
          <rule name="redirect15" stopProcessing="true">
           <match url="emailmandelivery.php" />
           <action type="Redirect" url="index.php" redirectType="Found" />
          </rule>
          <rule name="redirect16" stopProcessing="true">
           <match url="cron.php" />
           <action type="Redirect" url="index.php" redirectType="Found" />
          </rule>
          <rule name="redirect17" stopProcessing="true">
           <match url="upload/.*" />
           <action type="Redirect" url="index.php" redirectType="Found" />
          </rule>
          <rule name="rule 1R" stopProcessing="true">
           <match url="^Api/access_token$"  />
           <action type="Rewrite" url="/Api/index.php/access_token"  />
          </rule>
          <rule name="rule 2R" stopProcessing="true">
           <match url="^Api/V8/(.*?)$"  />
           <action type="Rewrite" url="/Api/index.php/V8/{R:1}"  />
          </rule>
          <rule name="rule 3R">
           <match url="^Api/(.*)$"  />
           <action type="Rewrite" url="/-"  />
          </rule>
         </rules>
        </rewrite>
        <caching>
         <profiles>
          <remove extension=".php" />
         </profiles>
        </caching>
        <staticContent>
         <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
        </staticContent>
              <defaultDocument>
                  <files>
                      <add value="index.php" />
                  </files>
              </defaultDocument>
       </system.webServer>
      </configuration>
    

So as you can see at the very bottom - the Api redirections are present (not sure if correct though). Before this redirection there was a 404 problem in postman API call.

  • After adding proper redirections the 404 problem was gone but there was this bug instead:

Fatal error: Uncaught RuntimeException: Unexpected data in output buffer. Maybe you have characters before an opening <?php tag? in C:\web_server\www\vendor\slim\slim\Slim\App.php:624

I dealt with it using this method:

but basically this is still a current issue on windows :frowning: So this repair now works but only until next update when I will have to adjust the files again.

  • after I repaired this I now have another bug :frowning: I really have no idea how to repair this one…

      Slim Application Error
      The application could not run because of the following error:
    
      Details
      Type: Error
      Message: Call to undefined function openssl_pkey_get_private()
      File: C:\web_server\www\vendor\lcobucci\jwt\src\Signer\OpenSSL.php
      Line: 46  
    

Could you please help me?

A recent support case on the Outlook Support Forums might be of help - https://store.suitecrm.com/support/SuiteCRM-official-outlook-plugin/3180

The Keys being incorrect are a known issue (I’ll poke some people about getting it in a release some times soon) however the slim error there I’m not sure about.

Thank you for your response. Thanks for the link but as you can see I have the exact same redirections in place :wink: I noticed one thing in a new version of SuiteCRM though. When I installed the new CRM it changed my .htaccess (I was not on IIS yet) and in older versions of SuiteCRM the rewrite rules were:

RewriteRule ^Api/access_token$ Api/index.php/access_token [L]
RewriteRule ^Api/V8/(.*?)$ Api/index.php/V8/$1 [L]

That was back on v. 7.11.13. When I updated last week to v. 7.11.16 (and now I am on 7.11.18) it changed my htaccess Api rules to this:

RewriteRule ^Api/access_token$ Api/index.php [L]
RewriteRule ^Api/V8/(.*?)$ Api/index.php [L]

Any idea why it would do this? Which version is correct? I guess the first one but why would suitecrm update change my htaccess to this new version ending with index.php only? :roll_eyes:

If I know which version is correct I can adapt it to work with IIS web.config I guess…

Sooo - I just succesfully migrated the CRM to amazon ec2 and its bloody awesome!!! Speed of DB queries and the SuiteCRM overall went up like 400% thats unbelievable! Also - API is working as expected now… Guess I am finally done with Windows as a server solution :smiley:

Thank you guys, developers, especially @pgr for this forum and everything you do! You are the best!

1 Like