hello,
I am using Resource owner password flow to get Acumatica token.
I am encountering an intermittent issue across all environments, including Production.
When we receive an application for processing, we call the Acumatica Get Customer endpoint using a valid authentication token. Occasionally (approximately once a day or every other day), the request fails because the response cannot be deserialized. Our application expects a JSON response, but instead receives an HTML page, as shown below.
We cache the authentication token and validate it each time it is retrieved from the cache. Token validation is based on the Date header returned in the token generation response to ensure the token has not expired.
Could you help us determine why the API is intermittently returning HTML instead of the expected JSON response, despite the token being valid?
Tokens:
return html response : LqGoqJP-MvG2Q44kKI_QEq0PqziBlrWXnInucaZS9w0
return Json (Valid): IPLN2zlT8ui3GzGoySRC2M5nyz0Xa-StJ3cup25MAnc
if (response.Headers.TryGetValues("Date", out var dates) &&
DateTimeOffset.TryParse(dates.FirstOrDefault(), CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out var start))
{
detail.TokenStartTime = start.UtcDateTime;
}
private static bool IsValid(AcumaticaTokenDetail token)
{
if (string.IsNullOrWhiteSpace(token.AccessToken)) return false;
if (!token.TokenStartTime.HasValue) return false;
return token.TokenStartTime.Value.AddSeconds(token.ExpireIn) > DateTimeOffset.UtcNow;
}
This is the error details:
Acumatica "GET Customer?$filter=CustomerId eq '1631506'" deserialization failed. Raw response: "<!DOCTYPE html>
<html>
<head>
<meta charset=\"utf-8\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
<base href=\"../\">
<link rel=\"icon\" type=\"image/x-icon\" href=\"Icons/site.ico\" />
<script defer src=\"Scripts/Error/vendors.80ce324be3a2b5d43ef9.bundle.js\"></script><script defer src=\"Scripts/Error/app.57987879c4fc02d63fac.bundle.js\"></script>
</head>
<body aurelia-app=\"main\">
</body>
</html>"