I am inserting records using the Dynamics web API batch insert operation. I am using the patch method and inserting on the alternate key. The response that I am receiving from the CRM is (response.Content) is giving the batch ID and the alternate keys that I have inserted. However, I'd like to fetch the GUIDs of the inserted records as well. Is there any way to read the GUIDs of the inserted records in the response itself. Using another query to get the GUIDs will be costly as I need to insert millions of records.
I tried using response.Content to read the response but as mentioned above, it did not include the GUIDs. I also tried running a different query to fetch the GUIDs of the specified alternate keys. This takes up a lot of time. Further, I tried generating GUIDs at the time of insertion (hence, eliminating the need of capturing them in the response) but the client doesn't want to use this method.
//This is how I am reading the response
HttpResponseMessage response = httpClient.SendAsync(request).Result;
var strCttResponse = await response.Content.ReadAsStringAsync();
//Please see the expected and actual result description
//Following is the sample response (for one record only). As you can see //it has only the alternate key and batch id.
--batchresponse_63bdc6fd-90f2-4a2b-b11d-ba4cc1d122f4
Content-Type: multipart/mixed; boundary=changesetresponse_ac69e917-8cf9-4ee8-8d4c-9d525ae6f4c3
--changesetresponse_ac69e917-8cf9-4ee8-8d4c-9d525ae6f4c3
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 1
HTTP/1.1 204 No Content
OData-Version: 4.0
Location: https://<URL>/api/data/v9.1/contacts(new_altkey_contact='46236')
OData-EntityId: https://<URL>/api/data/v9.1/contacts(new_altkey_contact='46236')
//--------------------------------------------------------------------------
The result that I am looking for should return the GUID of the inserted records as well. Something like:
Batch Id
https://<URL>/api/data/v9.1/contacts(new_altkey_contact='altkey')
GUID of the record