MIDAS API

API Troubleshooting

If you run into difficulties making API calls, the following solutions may be of use...
When making API calls with a valid key, the only response returned is "invalid api key"
Applies To:Making API calls via POST if your MIDAS system is cloud-hosted by us
Cause:POST parameters are removed during HTTP 302 server redirects
Solution 1:If you're making API calls to the domain "midas.hosting/your_midas_url/api.pl", update your code to make calls to "your_midas_url.mid.as/api.pl" instead, and ensure you're making calls via https instead of http
Solution 2:Make API calls via GET instead
When making API calls, the only response returned is "NULL"
Applies To:Using cURL in PHP to make API calls via HTTPS
Cause:Receiving a "NULL" response when making API calls in this way will likely be due to the problem that cURL on the server where your PHP script is running has not been configured to trust the HTTPS Certificate Authority (CA) of the server where your MIDAS system resides. There are two solutions to this problem
Solution 1:Add the following line to your PHP code (before you call curl_exec):

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

...this simply configures cURL to accept any server(peer) certificate. Whilst this is a quick solution, it isn't as secure as Solution 2:
Solution 2:The more secure option is to use the "CURLOPT_CAINFO" parameter. This is used to point towards a CA certificate that cURL should trust (and therefore any server/peer certificates issued by that CA will also be trusted). In order to do this, you'll need the CA certificate for the server where your MIDAS resides (if your MIDAS is cloud-hosted by us, you can obtain this certificate in a zip file by clicking here).
Upload the CA certificate to the server where your PHP script is running from, and then add the following lines to your PHP code:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/midas.hosting.crt");

(This third line assumes the .crt certification can be found in the same directory as your PHP script, otherwise you'll need to adjust the above path according)
Blank responses are received when making API calls
Applies To:Making API calls if your MIDAS system is cloud-hosted by us
Cause:Your IP address has been automatically blocked by our systems due to an excessive API call rate (i.e. flooding our servers with a high number of API calls in a short period of time)
Solution:Check the frequency with which calls are being made to the MIDAS API from your code, and if necessary reduce the rate at which these calls are made (to no more than 60 over a 30 second period). Once you've identified the cause of the excessive API calls in your code, and rectified, please contact us to have your IP address unblocked so that you can resume making API calls