Reputation: 3204
I am using Acumaticas contract based API and I need to create a new sales order. I am using C# and have imported the AcumaticaAPI service reference. So far I've been able to query some data, such as getting a list of all the sales orders. But I don't know how to create a sales order via the API nor can I find how to do this in the developer guide. Here is my code for getting a list of the sales orders:
public HttpResponseMessage AddSalesOrder(int id)
{
var binding = new System.ServiceModel.BasicHttpBinding()
{
AllowCookies = true,
MaxReceivedMessageSize = 655360000,
MaxBufferSize = 655360000
};
var address = new System.ServiceModel.EndpointAddress("http://acumaticasandbox.mydomain.com/TestCompany/entity/Default/5.30.001");
using (DefaultSoapClient client = new DefaultSoapClient(binding, address))
{
client.Login("myuser", "mypass", "Test Company", null, null);
Entity[] items = client.GetList(new SalesOrder(), false);
client.Logout();
return Request.CreateResponse(HttpStatusCode.OK, items);
}
}
-How would I modify this code in order to create a new sales order?
-Also, is there a way to create a batch of new sales orders say via an array of sales order objects or a file (csv) import through the API?
Upvotes: 1
Views: 1625
Reputation: 1404
You would first have to create the Sales Order object that you want to insert in the system.
SalesOrder so = new SalesOrder
{
OrderType = new StringValue { Value = "SO" },
CustomerID = new StringValue { Value = "ABARTENDE" },
Details = new SalesOrderDetail[]
{
new SalesOrderDetail
{
InventoryID = new StringValue {Value = "AACOMPUT01" },
Quantity = new DecimalValue {Value = 2m }
},
new SalesOrderDetail
{
InventoryID = new StringValue {Value = "AALEGO500" },
Quantity = new DecimalValue {Value = 4m }
}
}
};
These inventory value are taken from demo data.
Then you have to use a Put call to insert the new Sales Order in the system.
SalesOrder result = (SalesOrder)client.Put(so);
Of course this is a very basic Sales Order. If you look at all the fields in the Sales Order endpoint definition, these are all fields that you can add to the object being created and that will be inserted at the same time.
If you have access to the Acumatica University the course related to the Contract Based API is the I210. http://acumaticaopenuniversity.com/courses/i210-contract-based-web-services/
Upvotes: 2