Just wanted to mention that searchTypes=[SKU] seems to be invalid now, I get:
{
"Code": "-",
"Message": "Can't deserialize \"searchTypes\" parameter. Error: \"Unexpected character encountered while parsing value: S. Path '', line 1, position 1.\""
}
http://apps.linnworks.net/Api/Class/linnworks-spa-commondata-Inventory-ClassBase-Enums-StockInformationSearchType indicates that 'SKU' is the first valid enum, you just have to provide 0 instead of SKU, i.e.:
keyword=TOYCAR&loadCompositeParents=true&loadVariationParents=true&entriesPerPage=1&pageNumber=1&dataRequirements=[1,2]&searchTypes=[0]
The Factory just returns null (because Factory::GetResponse uses file_get_contents and doesn't actually present the error response to you, I had to debug it via Postman to see the error message) so I hope this helps someone.
By the way, in your second call you should use the Server value returned in $authorization. http://apps.linnworks.net/Api says "Servers
When you have authorized an account, you will be given a session token and a session server. You must use these details to access the account from then onwards." So your second call becomes:
$StockItemsFull = json_decode(Factory::GetResponse("Stock/GetStockItemsFull","keyword=TOYCAR&loadCompositeParents=true&loadVariationParents=true&entriesPerPage=1&pageNumber=1&dataRequirements=[1,2]&searchTypes=[SKU]",$authorization->Token, $authorization->Server));
There is code in Factory::GetResponse that adds the "/api/" part of the URL for you.
Stuart Cameron
I have really struggled with the Linnworks API documentation, no examples and nothing on Google to reference... so I thought I would share a little work to assist anyone else struggling;
(1) If you haven't already you'll need to register your API, obtaining your own unique applicationId, applicationSecret & token (you'll need these, they shouldn't be shared); http://apps.linnworks.net/Applications
(2) You'll need the Linnworks SDK, go ahead and download it from here; https://github.com/LinnSystems/LinnworksNetSDK.git
(3) House the files where you can reference from your web root, I put mine below root in an Includes folder and include like this in your php file (They are more files names according to the call you are making).
(4) Next Include the authorisation you obtained in step one;
(5) Next make your first call, here we are doing a SKU search for the SKU "TOYCAR";
(6) Your results will be returned as an array;
Hope this helps you get started
2 people have this question