简体   繁体   English

在批量插入记录后需要帮助从Dynamics 365 Web API给出的响应中提取CRM记录ID

[英]Need help fetching CRM Record ID from response given by Dynamics 365 Web API after batch Inserting records

I am inserting records using the Dynamics web API batch insert operation. 我正在使用Dynamics Web API批处理插入操作插入记录。 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. 我从CRM收到的响应是(response.Content),它给出了批次ID和我插入的备用键。 However, I'd like to fetch the GUIDs of the inserted records as well. 但是,我也想获取插入记录的GUID。 Is there any way to read the GUIDs of the inserted records in the response itself. 有什么方法可以读取响应本身中插入记录的GUID。 Using another query to get the GUIDs will be costly as I need to insert millions of records. 由于我需要插入数百万条记录,因此使用另一个查询来获取GUID将非常昂贵。

I tried using response.Content to read the response but as mentioned above, it did not include the GUIDs. 我尝试使用response.Content读取响应,但是如上所述,它不包含GUID。 I also tried running a different query to fetch the GUIDs of the specified alternate keys. 我还尝试运行其他查询以获取指定备用键的GUID。 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. 此外,我尝试在插入时生成GUID(因此,消除了在响应中捕获它们的需求),但是客户端不想使用此方法。

//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. 如您所见// //它只有备用键和批次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. 我正在寻找的结果也应该返回插入记录的GUID。 Something like: 就像是:

 Batch Id

 https://<URL>/api/data/v9.1/contacts(new_altkey_contact='altkey')

 GUID of the record

Can you please verify the Response for a single create outside of an Batch. 您能否验证批生产之外的单个创建的响应。 From what I have seen, you should also get the AlternateKey Back. 从我所看到的,您还应该返回AlternateKey。 You could also ask Microsoft if this is really intended. 您也可以问微软这是否真的有意。 Is there a Special reason why you Need the GUID back? 有特殊原因为什么需要GUID? Yes, Alternate Key are slower because CRM Needs to ask internally for the GUID, but this schould not make any Impact beside Large Data Imports, for Exmaple for inital Data Migration 是的,备用键比较慢,因为CRM需要在内部要求GUID,但这对于大数据导入(例如用于初始数据迁移的Exmaple)不会产生任何影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM