Create a Stock Item with Attributes
In this example, by using the contract-based REST API, you will create in MYOB Acumatica a stock item that has attributes specified. An attribute is a property of an object in the system that specifies additional information that is not defined by the standard properties of the object (that is, those supported by the standard UI elements).
To specify the values of attributes, you will use the Attributes field of the StockItem entity. To identify the attribute whose value you want to specify, in the AttributeID field of the AttributeValue entity, you can specify either the attribute identifier or the attribute name, which can be found in the Description box on the Attributes (CS205000) form.
System Preparation
Before you test the code below, you need to do the following to configure your client application and the MYOB Acumatica instance to be used:
- Deploy a new MYOB Acumatica instance with the T100 dataset. For details on deploying an instance, see Instance Deployment: To Deploy an Instance with Demo Data in the Installation Guide.
- If you use Postman as the client application for testing, in the IntegrationDevelopmentGuide.postman_collection.json collection, make sure that the collection’s variables have the proper values. This collection is located in the IntegrationDevelopment\Help folder of the Help-and-Training-Examples repository on GitHub.
- To sign in to the instance in the client application, use the tenant name (which you specified when you created the instance) and the MYSTORE branch.
Request
You can use the following request example to create a stock item record with attributes through the contract-based REST API.
<MYOB Acumatica instance URL>
is the URL of the MYOB Acumatica
instance (such as https://my.acumatica.com/MyInstance). You can omit the instance
name in the URL (that is, you can use https://my.acumatica.com) if the instance
is installed in the root of the website.PUT /entity/Default/24.200.001/StockItem?
$select=InventoryID,Attributes/AttributeDescription,Attributes/Value&
$expand=Attributes HTTP/1.1
Host: [<MYOB Acumatica instance URL>]
Accept: application/json
Content-Type: application/json
{
"InventoryID":{"value":"BASESERV1"},
"Description":{"value":"Baseline level of performance"},
"ItemClass":{"value":"STOCKITEM"},
"Attributes":[
{
"AttributeID":{"value":"Operation System"},
"Value":{"value":"Windows"}
},
{
"AttributeID":{"value":"SOFTVER"},
"Value":{"value":"Server 2012 R2"}
}
]
}