Hello, I have a process that syncs stockitems from Acumatica for use on an external eCommerce web application.
I download the images as part of the sync and store them in Azure storage. The web application loads the images from the storage accounts.
I am finding that when I download a batch of images...perhaps syncing 10 products in a batch, I will get the first 3 images and then the response stops sending any content. I get an HTTP 200, but I receive no bytes in my download.
If I slow down my process it seems to work better.
I have seen similar issues when calling the rest API. If I download 1 product at a time, if my sync process goes too fast, Acumatica sends empty results….no error or anything like that. I was able to work around that issue by downloading batches of stock items in groups of 500 and storing the raw JSON to the DB and then doing the ETL steps after.
Is there some sort of limit in Acumatica or a better approach to fetching the images? I have my service account set to unlimited requests.
Here is my code snippet:
public async Task<byte[]> DownloadImageAsync(string imageId, string fileName)
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", $"{Helper.CurrentAuthToken.Replace("Bearer ", "")}");
string fullPath = $"{_restClient.BaseUrl}files/{imageId}";
Uri uri = new Uri(fullPath);
using (HttpResponseMessage response = await client.GetAsync(uri))
{
using (Stream streamToReadFrom = await response.Content.ReadAsStreamAsync())
{
if (streamToReadFrom != null)
{
var bytes = this.streamToByteArray(streamToReadFrom);
return bytes;
}
}
}
}
return null;
}
Thank you for your help!
Best answer by Troy Vars
View original