Skip to main content

Since converting from SOAP, I’ve run into C# issues related specifically to the Sales Price (AR202000) page.  For instance, when using a PUT method to create a brand new Sales Price row, I need to use a CancellationToken to timeout after 5 seconds.  Otherwise, I need to wait 5+ minutes to get a response back (InnerException: Error while copying content to a stream).  This is very strange since there is no wait time at all using Postman.  This isn’t my biggest concern since I’ve worked around it with the timeout/cancellation.

My biggest problem occurs when using a PUT method just to retrieve a Sales Price row (using InventoryID/PriceType/PriceCode).  This can take anywhere between 1 second to 5 minutes just to retrieve a response.  I need to do this to retrieve the RecordID, which is a new REST requirement for deleting specific SalePrice rows.  I don’t receive any response errors like I do trying to create the Sales Price row.  This is drastically increasing the processing time compared to my SOAP implementation.  These particular REST issues aren’t happening with other Acumatica page as I haven’t run into these kind of issues before using HttpClient.

Did anyone else run into these issues or found a way around the huge extended wait time?

Here my code (the sharedClient is of type HttpClient/RESTmethod is the URL):

            var json = JsonSerializer.Serialize(body);
            var httpContent = new StringContent(json, Encoding.UTF8, "application/json");

            sharedClient.DefaultRequestHeaders.Accept.Clear();
            sharedClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            string result = string.Empty;

            using (CancellationTokenSource cancelAfterDelay = new CancellationTokenSource(TimeSpan.FromSeconds(seconds)))
            {
                var response = new HttpResponseMessage();
                if (post)
                    response = sharedClient.PostAsync(RESTmethod, httpContent, cancelAfterDelay.Token).Result;
                else
                    response = sharedClient.PutAsync(RESTmethod, httpContent, cancelAfterDelay.Token).Result;

                var respBody = response.Content.ReadAsStringAsync();
                result = respBody.Result;
            }
 

@bpgraves Strange that Postman works fine but you are getting issues for c# client. have you looked into C# client @ GitHub - Acumatica/AcumaticaRESTAPIClientForCSharp


@bpgraves Strange that Postman works fine but you are getting issues for c# client. have you looked into C# client @ GitHub - Acumatica/AcumaticaRESTAPIClientForCSharp

No I haven’t since the highest version offered is 22.200.001 and we’re in the process of upgrading to 2024R1.


Hi @bpgraves were you able to find a solution? Thank you!


Hi @bpgraves were you able to find a solution? Thank you!

I had to remove the cancellation token and add a filter to the top level JSON for InventoryID.  This drastically improved the time it took to insert a new SalesPrice and also removed my need to retrieve the added SalesPrice. Here’s more info:

 

This isn’t really a solution the question I asked but I currently don’t have a need to do what I asked.  If anyone else found a way to speed up the retrieval of an existing SalesPrice, please post your solution here.


Reply