Tony Lanzer
Tony Lanzer

Reputation: 291

Acumatica REST API error

I've been trying to get a simple Acumatica contract-based REST API GET call to work for many hours now, and all I'm getting is an error when it apparently times out: "A task was canceled.", with no inner exception. I've tried quite a few different examples trying to accomplish this with both .NET Core 2.0 and .NET Framework 4.7.1 , and always get this vague error. Note: The same calls in Postman work fine.

See the code below for my latest version of simplified code to try to just get something to work. The call to GetAsync is what hangs there for a couple of minutes and then throws the error.

var str = new StringContent(
    JsonConvert.SerializeObject(
        new
        {
            name = "admin",
            password = "admin",
            company = "Company",
            branch = ""
        }),
        Encoding.UTF8, "application/json");

string baseUrl = "http://localhost/AcuAmazon172040019";

using (HttpClient client = new HttpClient())
using (HttpResponseMessage res = await client.PostAsync(baseUrl + 
    "/entity/auth/login", str))
using (HttpResponseMessage res2 = await client.GetAsync(baseUrl + 
    "/entity/Default/6.00.001/salesorder/so/001337"))
using (HttpContent content = res2.Content)
{
    string data = await content.ReadAsStringAsync();

    if (data != null)
    {
        Console.WriteLine(data);
    }
}

Acumatica v17.204.0019

Upvotes: 0

Views: 885

Answers (1)

Nickolas Hook
Nickolas Hook

Reputation: 804

The URL you use (the endpoint, entity name and all parts of the entity key) are all case-sensitive. Use "SalesOrder" instead of "salesorder" and probably "SO" instead of "so"

"/entity/Default/6.00.001/SalesOrder/SO/001337"

Upvotes: 1

Related Questions