I sometimes get an error saving an order thru the API:
System.OperationCanceledException: The order has unresolved errors. Any outstanding errors must be resolved before the order can be saved.
Is there a way to retrieve the reason that would normally show in the UI? Eg. "Transaction type should be purchase if a seller or sales price is entered"
Thanks,
Peter
Error Saving Order
-
- Posts: 89
- Joined: Wed Nov 16, 2011 11:51 am
Re: Error Saving Order
There are messages available on the IOrder. You can examine their Level to see their severity, and act accordingly:
Code: Select all
using (IOrder order = OrderStore.NewOrder(spec))
{
try
{
// Manipulate your new order here
foreach (IOrderMessage message in order.GetMessages())
{
MessageBox.Show(message.Text);
}
if (!order.GetMessages().Any(m => m.Level == OrderMessageLevel.Error))
{
OrderStore.ApplyChanges(order);
}
}
finally
{
OrderStore.CloseOrder(order);
MessageBox.Show(string.Format("We successfully created order"));
}
}
-
- Posts: 92
- Joined: Tue Feb 04, 2014 3:34 pm
Re: Error Saving Order
I get an error: 'Order' does not contain a definition for 'GetMessages'
But the SDK version I have, which is a bit old(3.0.10820.130), shows it as a valid method on IOrder. I'll have to get the latest version and verify.
But the SDK version I have, which is a bit old(3.0.10820.130), shows it as a valid method on IOrder. I'll have to get the latest version and verify.
Re: Error Saving Order
You need to call GetMessages on the strongly typed IOrder reference, not on your dynamic order reference.