Someone asked I review & try to create a simplified template for Dataverse Batch Requests. I think I've built out much of a solution but I'm stuck with some final errors when I send the batch...
I'm basically trying to combine...
This batch create YouTube video: https://www.youtube.com/watch?v=e2zuEBdas0g
@Paulie78's batch delete blog: https://www.tachytelic.net/2021/11/power-automate-bulk-delete-dataverse/
The Dataverse batch documentation: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/execute-batch-operations-using-web-api
... so we can get some template batch Dataverse set-ups that do not require creating an Azure Application like in Paulie's blog and that also do not require looping to add each record to a variable like Untethered365's YouTube video.
I have created one set-up with the standard batch request and one using change sets. Neither is working but for different reasons.
The standard batch request runs the call successfully but nothing is created in the table. And the response that I get by using base64tostring on the $content doesn't contain much:
Inputs
{
"host": {
"connectionReferenceName": "shared_webcontents",
"operationId": "InvokeHttp"
},
"parameters": {
"request/method": "POST",
"request/url": "/api/data/v9.2/$batch",
"request/headers": {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
"If-None-Match": "null",
"Accept": "application/json",
"Content-Type": "multipart/mixed;boundary=batch_18748f86-a56a-43eb-a881-d2faee3586b6"
},
"request/body": "--changeset_18a52fa6-3edd-4387-9dce-bcaf81f5e637\nContent-Type: application/http\nContent-Transfer-Encoding: binary\n\nPOST /api/data/v9.2/crc5f_test HTTP/1.1\nContent-Type: application/json;type=entry\n\n{\"crc5f_name\":\"ABC0\"}\n\n--changeset_18a52fa6-3edd-4387-9dce-bcaf81f5e637\nContent-Type: application/http\nContent-Transfer-Encoding: binary\n\nPOST /api/data/v9.2/crc5f_test HTTP/1.1\nContent-Type: application/json;type=entry\n\n{\"crc5f_name\":\"ABC1\"}\n\n--changeset_18a52fa6-3edd-4387-9dce-bcaf81f5e637\nContent-Type: application/http\nContent-Transfer-Encoding: binary\n\nPOST /api/data/v9.2/crc5f_test HTTP/1.1\nContent-Type: application/json;type=entry\n\n{\"crc5f_name\":\"ABC2\"}\n\n\n--batch_18748f86-a56a-43eb-a881-d2faee3586b6--"
}
}


The change sets gets an error saying "The response is not in a JSON format" but it does return that each request within the batch encountered a 404 error
Inputs
{
"host": {
"connectionReferenceName": "shared_webcontents",
"operationId": "InvokeHttp"
},
"parameters": {
"request/method": "POST",
"request/url": "/api/data/v9.2/$batch",
"request/headers": {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
"If-None-Match": "null",
"Accept": "application/json",
"Content-Type": "multipart/mixed;boundary=batch_18748f86-a56a-43eb-a881-d2faee3586b6"
},
"request/body": "--batch_18748f86-a56a-43eb-a881-d2faee3586b6\nContent-Type: multipart/mixed; boundary=changeset_18a52fa6-3edd-4387-9dce-bcaf81f5e637\n\n--changeset_18a52fa6-3edd-4387-9dce-bcaf81f5e637\nContent-Type: application/http\nContent-Transfer-Encoding: binary\nContent-ID: 1\n\nPOST /api/data/v9.2/crc5f_test HTTP/1.1\nContent-Type: application/json;type=entry\n\n{\"crc5f_name\":\"ABC0\"}\n\n--changeset_18a52fa6-3edd-4387-9dce-bcaf81f5e637\nContent-Type: application/http\nContent-Transfer-Encoding: binary\nContent-ID: 2\n\nPOST /api/data/v9.2/crc5f_test HTTP/1.1\nContent-Type: application/json;type=entry\n\n{\"crc5f_name\":\"ABC1\"}\n\n--changeset_18a52fa6-3edd-4387-9dce-bcaf81f5e637\nContent-Type: application/http\nContent-Transfer-Encoding: binary\nContent-ID: 3\n\nPOST /api/data/v9.2/crc5f_test HTTP/1.1\nContent-Type: application/json;type=entry\n\n{\"crc5f_name\":\"ABC2\"}\n\n--changeset_18a52fa6-3edd-4387-9dce-bcaf81f5e637--\n--batch_18748f86-a56a-43eb-a881-d2faee3586b6--"
}
}
Request Body
--batch_18748f86-a56a-43eb-a881-d2faee3586b6
Content-Type: multipart/mixed; boundary=changeset_18a52fa6-3edd-4387-9dce-bcaf81f5e637
--changeset_18a52fa6-3edd-4387-9dce-bcaf81f5e637
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 1
POST /api/data/v9.2/crc5f_test HTTP/1.1
Content-Type: application/json;type=entry
{"crc5f_name":"ABC0"}
--changeset_18a52fa6-3edd-4387-9dce-bcaf81f5e637
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 2
POST /api/data/v9.2/crc5f_test HTTP/1.1
Content-Type: application/json;type=entry
{"crc5f_name":"ABC1"}
--changeset_18a52fa6-3edd-4387-9dce-bcaf81f5e637
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 3
POST /api/data/v9.2/crc5f_test HTTP/1.1
Content-Type: application/json;type=entry
{"crc5f_name":"ABC2"}
--changeset_18a52fa6-3edd-4387-9dce-bcaf81f5e637--
--batch_18748f86-a56a-43eb-a881-d2faee3586b6--

Outputs
{
"statusCode": 404,
"headers": {
"Cache-Control": "no-cache",
"x-ms-service-request-id": "2709843e-7f9b-462d-aa9e-c00d5826a0c0,83372510-6d41-4835-acd3-ab1abc9e28a7",
"Set-Cookie": "ARRAffinity=4e3eebc24cdbcaa0e02db39d6138fff60434c67bc35b47bc48e24f6500996011eb29bb4b19df1459d2ea781b605f33064b9fea1f144b525b9d7676625c4ffb5408DC64045EE3B6F3650153111; path=/; secure; HttpOnly,ReqClientId=f322fc9b-a60c-43f2-a367-376253ef08df; expires=Tue, 24-Apr-2074 01:45:11 GMT; path=/; secure; HttpOnly,orgId=c7bcc299-5799-4eef-89f6-4cb7db788477; expires=Tue, 24-Apr-2074 01:45:11 GMT; path=/; secure; HttpOnly,ARRAffinity=4e3eebc24cdbcaa0e02db39d6138fff60434c67bc35b47bc48e24f6500996011eb29bb4b19df1459d2ea781b605f33064b9fea1f144b525b9d7676625c4ffb5408DC64045EE3B6F3650153111; path=/; secure; HttpOnly",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"REQ_ID": "83372510-6d41-4835-acd3-ab1abc9e28a7",
"CRM.ServiceId": "CRMAppPool",
"AuthActivityId": "94e5feef-4a33-46d4-8921-b269458403f7",
"x-ms-dop-hint": "48",
"x-ms-ratelimit-time-remaining-xrm-requests": "1,200.00",
"x-ms-ratelimit-burst-remaining-xrm-requests": "7999",
"mise-correlation-id": "824722d6-343b-40f1-8f4d-f45ab5d737c7",
"OData-Version": "4.0",
"X-Source": "471441764398131032201981022342072422052515127891752058021994198150224828311156221,1672102032264615181561136322221302174321211541661731971841212445922454214216232136125",
"Public": "OPTIONS,GET,HEAD,POST",
"Timing-Allow-Origin": "*",
"x-ms-apihub-cached-response": "true",
"x-ms-apihub-obo": "false",
"Date": "Wed, 24 Apr 2024 01:45:11 GMT",
"Allow": "OPTIONS,GET,HEAD,POST",
"Content-Length": "900",
"Content-Type": "application/json",
"Expires": "-1"
},
"body": {
"error": {
"code": 404,
"source": "flow-apim-unitedstates-002-westus-01.azure-apim.net",
"clientRequestId": "9d66f57b-f329-471f-97d8-017cbd603f41",
"message": "The response is not in a JSON format.",
"innerError": "--batchresponse_0879d5b9-569d-4cad-b740-dea306b261fd\r\nContent-Type: multipart/mixed; boundary=changesetresponse_6e5882f6-619e-4a87-a8a3-c241e65e65d3\r\n\r\n--changesetresponse_6e5882f6-619e-4a87-a8a3-c241e65e65d3\r\nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID: 1\r\n\r\nHTTP/1.1 404 Not Found\r\nContent-Type: application/json; odata.metadata=minimal\r\nOData-Version: 4.0\r\n\r\n{\"error\":{\"code\":\"0x80060888\",\"message\":\"Resource not found for the segment 'crc5f_test'.\"}}\r\n--changesetresponse_6e5882f6-619e-4a87-a8a3-c241e65e65d3--\r\n--batchresponse_0879d5b9-569d-4cad-b740-dea306b261fd--\r\n"
}
}
}
What is wrong with either of my calls and how can I fix either of them?
@Paulie78 @DamoBird365