This project intends to provide example usage of the Spire REST API using Microsoft .NET Framework 4.6. The project will build and run as is, and can be modified to suit your own requirements.
Instantiate an API client with a company name, username, and password:
var client = new ApiClient("test", "username", "password");
Create a new inventory item:
var inventoryClient = new InventoryClient(client);
var inventory = new Inventory();
inventory.whse = "00";
inventory.partNo = "TESTPART";
inventory.type = InventoryType.Normal;
inventory.status = InventoryStatus.Active;
inventory.description = "Test Inventory";
inventory = inventoryClient.Create(inventory);
List inventory matching the query "TEST":
foreach (var i in inventoryClient.List(0, 100, "TEST"))
{
Console.WriteLine(i.partNo);
}
Retrieve an inventory item by ID:
inventory = inventoryClient.Fetch(inventory.id);
Update a field on an existing inventory item:
inventory.description = "New Description";
inventoryClient.Update(inventory.id, inventory);
Delete an inventory item (if inventory is in use this will throw an
ApiException
):
inventoryClient.Delete(inventory.id);
Please see the following for the most up-to-date documentation:
- API Documentation (requires Spire Server)
- RestSharp
- Json.NET
- REST API Tutorial