Announcements
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
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?
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156