Post multiple records to business central

I am trying to post multiple records to a business central, via the OData API, but not successful. I am however able to insert a record at a time.
Any assistance on how to go about this, is highly appreciated.
Below are screenshots of my postman.



My post url is as follows: https://api.businesscentral.dynamics.com/v2.0/xxxxxxxxxxxxxxxxx/Development10/ODataV4/Company(‘xxxxxx’)/HRJobGradesList
Ps. I am new to postman.

Does that API support multiple records at the same time?

If not, then you might need to create some sort of loop, or a data driven test using the test runner.

Is there any error information returned by the API?

If you are new to Postman. I would recommend going through the Postman training if you haven’t done so yet.

Postman Galaxy Training | Postman API Network

Run through the “APIs 101 Training”, then the “Testing and Automation Training” course.

The following links provide a bit more info about data driven testing.

Importing data files | Postman Learning Center

API Testing ‘A Beginners View’: Data-driven testing in Postman - Community showcase - Postman

1 Like

Thank you @michaelderekjones for this insightful links.
Yes, OData does support multiple records. Here’s how I managed it, by using $batch:


Whereas I am still trying to better understand the solution (it works):

  1. “request” is a predetermined variable.
  2. “id” is array key of each value in my array
  3. “url” consists of Business Central 's company name

then there’s the header and body. Body consisting of values to be inserted into the BC table.
The area with black shadding on POST is the MS Azure tenant ID.

A more better explanation of this will go a long way to helping understand the whole dynamic of the solution.

The body you have posted is an JSON array of objects. (It’s also a JSON object in its own right).

The requests element is an array.

JSON uses key\value pairs. You can have arrays within arrays. (Structures can get complicated - there are tools on the web that help visualise complex JSON).

How an API will accept data is largely down to the API. I haven’t looked up the ODataV4 standard to see if the requests\method’s you have follow that standard or if its just how this API works.

I would say that the ability to post multiple requests at the same time preventing the need to write extra code to loop through requests appear to be a good design feature of this API.

Even better, it looks like you can submit different types of data in the same request through the URL.

I don’t know if that’s part of the core Dynamics API, or has been extended by the supplier. (We use Dynamics but I haven’t been that involved in testing it, I do know it has well documented API’s that can be used to inject test data to setup the known state before a particular test - just haven’t used it in anger).

1 Like