Magento – Magento SOAP API call limit

apiPHPrestsoap

Is there a limit on API calls using Magento's SOAP API (V1)? The product page for a store I'm working on requires several calls to the "cataloginventory_stock_item.list" method, once for every "simple product" associated with the "configurable product." This method returns an array of product details, but only up to five calls, after which, I run into an error.

For example: Products (by id) 18730 through 18741 are all simple products that represent different options for the configurable product of id 18742. The following code loops through these ids and performs the aforementioned API call, using the id as an argument.

$client  = new SoapClient("http://WEBSITE.com/magento/api/soap/?wsdl");
$session = $client->login(USERNAME, PASSWORD);

for($id = 18730; $id < 18742; $id++){
    $result = $client->call($session, 'cataloginventory_stock_item.list', $id);
    echo "<p>" . json_encode($result) . "</p>";
}

The result is as follows:

[{"product_id":"18730","sku":"FF016077-M-F. Grey","qty":"3.0000","is_in_stock":"1","use_config_manage_stock":"1","manage_stock":1,"min_sale_qty":1,"is_qty_decimal":"0","enable_qty_increments":false,"qty_increments":false}]

[{"product_id":"18731","sku":"FF016077-M-P.Green","qty":"1.0000","is_in_stock":"1","use_config_manage_stock":"1","manage_stock":1,"min_sale_qty":1,"is_qty_decimal":"0","enable_qty_increments":false,"qty_increments":false}]

[{"product_id":"18732","sku":"FF016077-M-U. Blue","qty":"2.0000","is_in_stock":"1","use_config_manage_stock":"1","manage_stock":1,"min_sale_qty":1,"is_qty_decimal":"0","enable_qty_increments":false,"qty_increments":false}]

[{"product_id":"18733","sku":"FF016077-L-F. Grey","qty":"5.0000","is_in_stock":"1","use_config_manage_stock":"1","manage_stock":1,"min_sale_qty":1,"is_qty_decimal":"0","enable_qty_increments":false,"qty_increments":false}]

[{"product_id":"18734","sku":"FF016077-L-P.Green","qty":"2.0000","is_in_stock":"1","use_config_manage_stock":"1","manage_stock":1,"min_sale_qty":1,"is_qty_decimal":"0","enable_qty_increments":false,"qty_increments":false}]

Fatal error: Uncaught SoapFault exception: [HTTP] Forbidden

I know that this error is triggered by the fifth iteration, not by any property of the product of id 18735, because if I initialize the for-loop at 18735, I get the following:

[{"product_id":"18735","sku":"FF016077-L-U. Blue","qty":"3.0000","is_in_stock":"1","use_config_manage_stock":"1","manage_stock":1,"min_sale_qty":1,"is_qty_decimal":"0","enable_qty_increments":false,"qty_increments":false}]

[{"product_id":"18736","sku":"FF016077-XL-F. Grey","qty":"4.0000","is_in_stock":"1","use_config_manage_stock":"1","manage_stock":1,"min_sale_qty":1,"is_qty_decimal":"0","enable_qty_increments":false,"qty_increments":false}]

[{"product_id":"18737","sku":"FF016077-XL-P.Green","qty":"1.0000","is_in_stock":"1","use_config_manage_stock":"1","manage_stock":1,"min_sale_qty":1,"is_qty_decimal":"0","enable_qty_increments":false,"qty_increments":false}]

[{"product_id":"18738","sku":"FF016077-XL-U. Blue","qty":"3.0000","is_in_stock":"1","use_config_manage_stock":"1","manage_stock":1,"min_sale_qty":1,"is_qty_decimal":"0","enable_qty_increments":false,"qty_increments":false}]

[{"product_id":"18739","sku":"FF016077-XXL-F. Grey","qty":"1.0000","is_in_stock":"1","use_config_manage_stock":"1","manage_stock":1,"min_sale_qty":1,"is_qty_decimal":"0","enable_qty_increments":false,"qty_increments":false}]

Fatal error: Uncaught SoapFault exception: [HTTP] Forbidden 

This is also a very recent problem. Up until only a few days ago, I had not encountered this error. Perhaps a patch enforced a limit on API calls? If so, is there a way to fix this? Or is there a better API method for retrieving a configurable product's associated simple products?

Best Answer

I don't know if you solved the problem or not but I think there is a software in your server that limits the number of requests for your api/server.

I think you should have created some intervals between requests.