
Hi, according to MS documentation
the sample for create an account like this
POST [Organization URI/api/data/v9.0/accounts HTTP/1.1
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
Accept: application/json
{
"name": "Sample Account"
}
but i can't send an array like this
[{
"name": "Sample Account1"
},
{
"name": "Sample Account2"
},
{
"name": "Sample Account3"
}...]
How to do that? Thanks.
Hi Pablo,
We need to use "orgURL/api/data/v9.1/$batch" to insert multiple records in single request.
Here is an example with Postman:
Body:
Clofly123 is a unique identifier of the request body, d291f184-3d87-44a2-b12d-6fc13a4d4d9c is a randomly generated GUID.
You can change them to your own string or guid.
--batch_Clofly123
Content-Type: multipart/mixed; boundary=changeset_d291f184-3d87-44a2-b12d-6fc13a4d4d9c
--changeset_d291f184-3d87-44a2-b12d-6fc13a4d4d9c
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 1
POST https://company.crm5.dynamics.com/api/data/v9.1/accounts HTTP/1.1
Content-Type: application/json
{
"name":"aaa"
}
--changeset_d291f184-3d87-44a2-b12d-6fc13a4d4d9c
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 2
POST https://company.crm5.dynamics.com/api/data/v9.1/accounts HTTP/1.1
Content-Type: application/json
{
"name":"An account"
}
--changeset_d291f184-3d87-44a2-b12d-6fc13a4d4d9c--
--batch_Clofly123--
Headers:
Content-Transfer-Encoding: binary
Content-Type: multipart/mixed; boundary=changeset_d291f184-3d87-44a2-b12d-6fc13a4d4d9c
Result(success):
The status code is 200, and it will return batchresponse text in its response message.
Please refer to following links for more details about batch operation:
Regards,
Clofly