Answered

Inventory::GetInventoryItems Record Count

 

 

 

On the last line 1,10 indicates start at the first record and retrieve 10 more right?  How do I establish how many Inventory Items I have so that I can retrieve them all, setting a higher figure than the amount of records available displays an error.

require_once('Inventory.php');
require_once('Factory.php');
$authorization = json_decode(Factory::GetResponse("Auth/AuthorizeByApplication", "applicationId=0000&applicationSecret=0000&token=0000", "", "https://api.linnworks.net/"));
$views = Inventory::GetInventoryViews($authorization->Token, "https://api.linnworks.net/");
$locations = Inventory::GetStockLocations($authorization->Token, "https://api.linnworks.net/");
$locationIds = array();
$inventoryItems = Inventory::GetInventoryItems($views[0],$locationIds,1,10,$authorization->Token,"https://api.linnworks.net/");
If I try (which is how I interpret the documentation), then I receive an error, so I am obviously missing something fundamental
$InventoryItemsCount = Inventory::GetInventoryItemsCount(true,true,$authorization->Token,"https://api.linnworks.net/");
echo $InventoryItemsCount;

tIFZWr3jWjKcqDOoG3ibgydAfxVu5my-fg.png

Thanks in advance for the direction and assistance

 

Answer

Hello,

If you want to pull all of your inventory items, you can run http://apps.linnworks.net//Api/Method/Stock-GetStockItems call with empty keyword.



Here is the raw request for GetInventoryItemsCount:


POST https://ext.linnworks.net//api/Inventory/GetInventoryItemsCount HTTP/1.1

Host: ext.linnworks.net

Connection: keep-alive

Content-Length: 40

Accept: application/json, text/javascript, */*; q=0.01

Origin: https://www.linnworks.net

User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36

Accept-Language: en

Authorization: YOUR TOKEN

Content-Type: application/x-www-form-urlencoded; charset=UTF-8

Referer: https://www.linnworks.net/

Accept-Encoding: gzip, deflate, br


Body:

 

includeDeleted=true&includeArchived=true



Worked like a charm.


Login to post a comment