Randem Systems Support Board

OpenCart => OpenCart MODS => Topic started by: Randem on January 28, 2016, 10:47:21 PM

Title: API problems - What you need to know
Post by: Randem on January 28, 2016, 10:47:21 PM
        When you start to have API problems, and at one time or another you will (unless you are really lucky).
These are the reasons you may have it along with how to fix it. It is a relatively simple problem but it is hidden by AJAX calls.
Since you cannot see what is happening; this can be a maddening problem because the errors do not show in the system error log.

The errors are such:

        I will first go thru the issues that make this type of thing happen.
In your multi-store settings you have URL's that not only do not resolve to the same IP address but they also have to resolve to the same folder
on the same server. This can happen on multi-store setups but is more prevalent on multi-store conversions (upgrades) than anything else or stores that have been moved from a folder to the root or vice-versa.
There should be no way for this to happen on a single store setup unless it was changed from multi-store to single store and it had previous orders from the other stores or the store was moved to a different location
and there were orders with the address of the old location stored in the orders table. This is also why it only appears when you attempt to edit orders. I was informed by OSWorX to add another possible element in things like this happening because one has edited a language or source file and saved it in the incorrect format (BOM or/and as ANSII instead of UTF-8). Of course when the system reads this file it will be incomplete and can cause all sort of other misdeeds also.

        OpenCart somehow gets the wrong URL of a store from one of it queries and if the URL points to another folder on your hosted system, this is where the fun begins...
The AJAX calls use the bad URL to make it's call to login, The login fails because the AJAX call is attempting to run code in the incorrect folder.
Now the interesting part of this is if you actually have an index.php file in that folder it will execute that code; which can cause unpredictable results on your system.
Now when the call returns or times out, it failed and you get the message that your IP address is not permitted to use API.
You can go thru the exercise of creating a new API, assigning it to your store etc... as many times as you like and none of it will matter; you will continue to get the same error (this is when you start to curse uncontrollably).

To fix do the following:

Other Helpful Information (https://randemsystems.com/support/opencart/)