web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Bad Request in Post to Item Journal from Customized Table

(0) ShareShare
ReportReport
Posted on by 36

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?

My code:

   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');

                if not Http_Client.Post('api.businesscentral.dynamics.com/.../Company/----------------------/EVS_ItemJournalLine', Content, ResponseMessage) then
                    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;
I have the same question (0)
  • Verified answer
    DAnny3211 Profile Picture
    11,423 Super User 2026 Season 1 on at

    Hi

    if 200 or 300 rows are successful, it makes me think that there might be some error in the data in your custom table, also because it seems to me from your code that you make one call per row, so I don't think there are any limitations on the number of rows.

    Double-check the data in your table

    DAniele

  • Verified answer
    YUN ZHU Profile Picture
    102,590 Super User 2026 Season 1 on at

    Hi, I also think it is a data problem. If it is a size limit, the error message is different.

    429 - Too Many Requests or 413: Request Entity Too Large.

    More details:

    https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/dynamics-current-limits

    Hope this helps as well.

    Thanks.

    ZHU

  • Abdul Mateen Profile Picture
    36 on at

    Yes it's a data Problem. Thank you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 580 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 462 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 272 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans