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?