I am posting thousands of inventory from my Business Central customized table to Business Central Item Journal Odata Api through Rest and it does posting limited transaction while debuging in repeater but it stops at some 200 or 300 row of table with the error of 400 Bad Request, i wanted to know is thiis due to large no of records or what? and what is the solution?
TblTestInventory.Init();
TblTestInventory.Reset();
TblTestInventory.SetRange(TblTestInventory.IsSync, false);
TblTestInventory.SetRange(TblTestInventory.ERP_No, '');
if TblTestInventory.find('-') then begin
repeat begin
Clear(JObject);
Clear(jsonText);
Clear(Content);
Clear(ResponseMessage);
ChecKtransid := TblTestInventory."Transaction id";
batch := format(Date2DMY(TblTestInventory.BUSINESS_DATE, 2)) + '-' + FORMAT(TblTestInventory.BUSINESS_DATE, 0, '<Month Text,3>');
JObject.Add('Journal_Template_Name', 'COGS');
JObject.Add('Journal_Batch_Name', batch);
JObject.Add('Posting_Date', TblTestInventory.BUSINESS_DATE);
JObject.Add('Entry_Type', 'Sale');
JObject.Add('Item_No', TblTestInventory.SKU);
JObject.Add('Quantity', TblTestInventory.QUANTITY);
JObject.Add('Location_Code', TblTestInventory.Location);
JObject.Add('Shortcut_Dimension_1_Code', TblTestInventory.Location);
JObject.Add('Shortcut_Dimension_2_Code', 'OPERATIONS');
JObject.WriteTo(jsonText);
Content.WriteFrom(jsonText);
Content.GetHeaders(contentHeaders);
contentHeaders.Remove('Content-Type');
contentHeaders.Add('Content-Type', 'application/json');
Error('The call to the web service failed.');
if not ResponseMessage.IsSuccessStatusCode() then
Error('The web service returned an error message:\\' + 'Status code: ' + Format(ResponseMessage.HttpStatusCode()) + 'Description: ' + ResponseMessage.ReasonPhrase());
// for is sync and document no
if ResponseMessage.IsSuccessStatusCode() = true then begin
ResponseMessage.Content().ReadAs(responseString);
if Json_TokenR.ReadFrom(responseString) then begin
if Json_TokenR.IsObject then begin
Json_ObjectR := Json_TokenR.AsObject();
if GetResultJsonValue(Json_ObjectR, 'Document_No', Json_ValueR) then begin
TblTestInventory.ERP_No := Json_ValueR.AsText();
end;
end;
end;
TblTestInventory.IsSync := true;
TblTestInventory.Modify();
end;
// for is sync and document no
end until TblTestInventory.Next = 0;