0
votes

I am attempting to retrieve a single sales order based on the Customer Order field in Acumatica with the Contract Based API. See my code below, which I based off of code in the Contract Based Documentation (page 82).

public SalesOrder GetSalesOrder(string orderNumber)
{
    var binding = new System.ServiceModel.BasicHttpBinding()
    {
        AllowCookies = true,
        MaxReceivedMessageSize = 655360,
        MaxBufferSize = 655360,
        SendTimeout = new TimeSpan(0, 2, 0)
    };

    var soToBeFound = new SalesOrder()
    {
        OrderType = new StringValue { Value = "SO" },
        CustomerOrder = new StringValue { Value = orderNumber }
    };

    var address = new System.ServiceModel.EndpointAddress(ConfigurationManager.AppSettings["AcumaticaUrl"]);


    using (DefaultSoapClient client = new DefaultSoapClient(binding, address))
    {
        client.Login(_acumaticaUid, _acumaticaPwd, _acumaticaCompany, null, null);

        var existingOrder = (SalesOrder)client.Get(soToBeFound);

        client.Logout();

        return existingOrder;
    }
}

When I execute this code I get this exception:

The request channel timed out while waiting for a reply after 00:01:59.9880722. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout."

As you can see, I've already increased the timeout to 2 minutes, which seems like forever. Is the Acumatica API really just this slow? Or am I doing something wrong in code?

EDIT:

When I try to get by the "OrderNbr" field instead of "CustomerOrder" field, it works perfectly. Is getting by "CustomerOrder" not allowed in this way? If not, how can I use "CustomerOrder" in a get request?

1

1 Answers

2
votes

When you do search via the Contract-Based API, it's required to assign instance of the [FieldType]Search type instead of [FieldType]Value to all fields used in search criteria (StringSearch must be used instead of StringValue in your case):

var soToBeFound = new SalesOrder()
{
    OrderType = new StringSearch { Value = "SO" },
    CustomerOrder = new StringSearch { Value = orderNumber }
};

Just to confirm, StringSearch is also used in the sample on page 82 from the Contract Based documentation.