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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

How am I supposed to programmatically update multiple records in one http-call using batch?

(0) ShareShare
ReportReport
Posted on by 30

Hello,

I am currently trying to update multiple records (based on the same key) using only one http-call. 
I have already found out that I have to use $batch on the odata4-server, but I can't figure out how to execute multiple calls;

Context:

One user can have multiple sessions, and based on the latest login I want to set the latest session to active, and all others to inactive.
So I have to do a PUT-request to my Session table for each of the sessionrecords of the account.
(Ignoring the fact that I need to do GET-requests first to get the E-tag).

My batch-headers are as following:
Content-Type: multipart/mixed;boundary=<batch_guid>
OData-MaxVersion: 4.0
OData-Version: 4.0

My batch requestbody is as following:

--
Content-Type: multipart/mixed; boundary=

--
Content-Type: application/http
Content-Transfer-Encoding:binary
Content-ID: 1

POST  HTTP/1.1
Content-Type: application/json; charset=utf-8
Accept: application/json

{
    "ConsumerId": '06cc6ba3-ab18-405b-b6ef-7a7efd56a1eb'
}
----

--
Content-Type: application/http
Content-Transfer-Encoding:binary
Content-ID: 2

POST <>WebserviceEndpoint> HTTP/1.1
Content-Type: application/json; charset=utf-8
Accept: application/json

{
    "ConsumerId": '06cc6ba3-ab18-405b-b6ef-7a7efd56a1ec'
}

----
----


I am only able to execute one changeset (so one http-call effectively) because I need to set the batch-boundary to a certain changeset.
Without doing so I get the error: 

The content type 'multipart/mixed' specifies a batch payload; however, the payload either does not include a batch boundary or includes more than one boundary. In OData, batch payload content types must specify exactly one batch boundary in the 'boundary' parameter of the content type.


When I give all my changesets the same guid, I get the following error:
Multiple requests within the same change set are not supported by Dynamics 365 Business Central OData web services.
So my question is, how can I (using REST) update multiple records using only one http-call?

  • Verified answer
    RamonP Profile Picture
    30 on at

    I already managed to fix it myself. It turned out I had to use a different structure for the requestbody, in which I specifically create new batches (with the same uuid*) in which I specify the changesets individually.

  • Andy Sather Profile Picture
    Microsoft Employee on at

    Thank you for replying the solution to your post.

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

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 570 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 390 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 220 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans