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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Array in API POST

(0) ShareShare
ReportReport
Posted on by

Hi all,

I am populating a line items related to a Job table using Custom API. My custom API is working fine with GET, PATCH, POST when I send single record. However, in my case I would like to send multiple lines. Is it possible to have array of items in JSON in BC Custom API? I am using version 16.x but soon will be upgrading to 19.1

Let me know if anyone come across same requirement in one of your project.

Table: Job (will be created by end user)

Table: Job Lines ( I would like to populate using API)

{
"value": [
{

"JobNo": "A00600",
"LineNo": 2000,
"CostType": "Material",
"Quantity": 10,

"Price" : 100

}
]
}

I tried array in POST but no luck, getting message back from API

"message": "An unexpected 'StartArray' node was found when reading from the JSON reader. A 'StartObject' node was expected.  CorrelationId:  6ec8513d-5334-471f-a3a1-fdb4b82d97ab."

[

 {

  Payload

 },

 {

  Payload

 }

]

Best Regards,

Farooq 

I have the same question (0)
  • Lars Lohndorf-Larsen Profile Picture
    on at

    Hello,

    You can insert multiple lines using json arrays. Here is an example from the standard api purchaseOrders where we insert one order with 2 lines and 2 dimensions (update ItemID to match your own items):

    POST MyPC:7048/.../purchaseOrders

    HEADER:

    Content-Type = application/json

    BODY

        {  

                        "vendorNumber": "20000",

                        "purchaseOrderLines":

                        [

                          {"itemId" : "7192b134-2a0f-ed11-b845-6045bd8e5eb4"},

                          {"itemId" : "7392b134-2a0f-ed11-b845-6045bd8e5eb4"}

                        ],

                                            "dimensionSetLines":

                        [

                            {

                          "code": "DEPARTMENT",

                           "valueCode": "SALES"

                            }

                         ]

        }

    or maybe its just the syntax of the array that is missing a ,{( or somethien else?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,238

#2
YUN ZHU Profile Picture

YUN ZHU 773 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 630

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans