Dynamics CRM 2015/2016/365 Web API:批处理任务

Web API为我们提供的批量任务执行功能,我们可以在一个请求中混合多个不相干的创建查询请求,并且其还提供了事务功能,如果在事务中如果有脚本出现了错误,则其提供回滚功能。

如下是批处理的请求报文,在报文里面我们需要设置批处理任务的编号,因为我们需要用它来划分任务的开始和结束边界。另外,我们还可以通过changeset标记来划分事务,在同一个changeset中,如果有处理失败了,那么整个changeset都会被回滚。

POST https://crmhomedev06.api.crm6.dynamics.com/api/data/v8.2/$batch HTTP/1.1
Accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IlJyUXF1OXJ5ZEJWUldtY29jdVhVYjIwSEdSTSIsImtpZCI6IlJyUXF1OXJ5ZEJWUldtY29jdVhVYjIwSEdSTSJ9.eyJhdWQiOiJodHRwczovL2NybWhvbWVkZXYwNi5hcGkuY3JtNi5keW5hbWljcy5jb20vIiwiaXNzIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvYmI4Y2IyMmUtY2VhOC00ZTQwLWJiM2ItNmIxZGEwMzg4MDEwLyIsImlhdCI6MTQ3OTM1ODkyNiwibmJmIjoxNDc5MzU4OTI2LCJleHAiOjE0NzkzNjI4MjYsImFjciI6IjEiLCJhbXIiOlsicHdkIl0sImFwcGlkIjoiNTYzOTI3NDktZDlmOS00NzZmLWIyM2QtZmE3ZGZkYjdlZjQzIiwiYXBwaWRhY3IiOiIwIiwiZV9leHAiOjEwODAwLCJmYW1pbHlfbmFtZSI6Inhpb25nIiwiZ2l2ZW5fbmFtZSI6ImplZmYiLCJpcGFkZHIiOiIyMDcuNDYuMTM5LjI0OSIsIm5hbWUiOiJqZWZmIHhpb25nIiwib2lkIjoiNTg3ODk2NGUtNzVhMy00MmE5LTkyMTItMGY2YWFkMGEyN2U5IiwicGxhdGYiOiIzIiwicHVpZCI6IjEwMDM3RkZFOUJEMEY2QTIiLCJzY3AiOiJ1c2VyX2ltcGVyc29uYXRpb24iLCJzdWIiOiI0U3A4Z2htQUdBSlNvQnpJOFM0M1RJWmxzbHZQNTRFdFpxTEh3Qm44Y0ZjIiwidGlkIjoiYmI4Y2IyMmUtY2VhOC00ZTQwLWJiM2ItNmIxZGEwMzg4MDEwIiwidW5pcXVlX25hbWUiOiJqZWZmLnhpb25nQGNybWhvbWVkZXYwNi5vbm1pY3Jvc29mdC5jb20iLCJ1cG4iOiJqZWZmLnhpb25nQGNybWhvbWVkZXYwNi5vbm1pY3Jvc29mdC5jb20iLCJ2ZXIiOiIxLjAiLCJ3aWRzIjpbIjYyZTkwMzk0LTY5ZjUtNDIzNy05MTkwLTAxMjE3NzE0NWUxMCJdfQ.I_j1DNlvKJcEuEziVCQ83hF3j5FsJkBFwvQY9SvdcVQTOEZOq69_X7GqfDOnEvOi58dZCCiCcJW2N73PY9QgxIKxOSJ3FBJfl4c6OywcDfgLSMUJ9HScXC3HTHO8pnoQwREl9b83DHN3wqAeQudVs-hMH7-3vtpV95Ro0vNGcaw2zvQjDxm9ajIo5h7oq12fWLQe40di5dOeokokxBAqNUFP3huo_Z3w4o-TYPZERg3fBo_ErwGnvWinnJxBXjJIvJy9o5RSa6RLopITdXIWfr6s5-jTEtrr5MGhwqs3hzKPlrffpC85LP98mhGQLpg2fZD-aB96x_uWmHi_SwGT7A
Content-Type: multipart/mixed; boundary=batch_AAA123
Host: crmhomedev06.api.crm6.dynamics.com
Content-Length: 1105
Expect: 100-continue

--batch_AAA123
Content-Type: multipart/mixed;boundary=changeset_BBB456

 --changeset_BBB456
Content-Type: application/http
Content-Transfer-Encoding:binary
Content-ID: 1

 POST https://crmhomedev06.crm6.dynamics.com/api/data/v8.2/tasks HTTP/1.1
 Content-Type: application/json;type=entry

 {‘subject‘:‘Task 1 in batch‘,‘[email protected]‘:‘https://crmhomedev06.crm6.dynamics.com/api/data/v8.2/accounts(5df6e552-bca5-e611-8100-1458d05b1178)‘}
--changeset_BBB456
Content-Type: application/http
Content-Transfer-Encoding:binary
 Content-ID: 2

 POST https://crmhomedev06.crm6.dynamics.com/api/data/v8.2/tasks HTTP/1.1
Content-Type: application/json;type=entry

 {‘subject‘:‘Task 2 in batch‘,‘[email protected]‘:‘https://crmhomedev06.crm6.dynamics.com/api/data/v8.2/accounts(5df6e552-bca5-e611-8100-1458d05b1178)‘}
-changeset_BBB456--

--batch_AAA123
Content-Type: application/http
Content-Transfer-Encoding:binary
GET https://crmhomedev06.crm6.dynamics.com/api/data/v8.2/accounts HTTP/1.1
Accept: application/json

--batch_AAA123--

批处理任务响应报文

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: multipart/mixed; boundary=batchresponse_c01b10e0-01f1-4b2b-8fb9-390b7d8166d4
Expires: -1
Server: Microsoft-IIS/8.5
REQ_ID: 764a9d7b-17be-4ebe-98c1-acb21c1e68ba
Set-Cookie: ReqClientId=c4e5658f-bd22-4e41-9328-2e4481d75142; expires=Wed, 17-Nov-2066 06:43:07 GMT; path=/; secure; HttpOnly
OData-Version: 4.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Thu, 17 Nov 2016 06:43:15 GMT
Content-Length: 342441
Strict-Transport-Security: max-age=31536000; includeSubDomains

--batchresponse_c01b10e0-01f1-4b2b-8fb9-390b7d8166d4
Content-Type: multipart/mixed; boundary=changesetresponse_10c4be12-1f1e-4d5a-9cbf-51bb6c390615

--changesetresponse_10c4be12-1f1e-4d5a-9cbf-51bb6c390615
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 1

HTTP/1.1 204 No Content
OData-Version: 4.0
Location: https://crmhomedev06.crm6.dynamics.com/api/data/v8.2/tasks(9a932b1d-91ac-e611-80f9-1458d05a2ab0)
OData-EntityId: https://crmhomedev06.crm6.dynamics.com/api/data/v8.2/tasks(9a932b1d-91ac-e611-80f9-1458d05a2ab0)

--changesetresponse_10c4be12-1f1e-4d5a-9cbf-51bb6c390615
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 2

HTTP/1.1 204 No Content
OData-Version: 4.0
Location: https://crmhomedev06.crm6.dynamics.com/api/data/v8.2/tasks(9b932b1d-91ac-e611-80f9-1458d05a2ab0)
OData-EntityId: https://crmhomedev06.crm6.dynamics.com/api/data/v8.2/tasks(9b932b1d-91ac-e611-80f9-1458d05a2ab0)

--changesetresponse_10c4be12-1f1e-4d5a-9cbf-51bb6c390615--
--batchresponse_c01b10e0-01f1-4b2b-8fb9-390b7d8166d4
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0

{
  "@odata.context":"https://crmhomedev06.crm6.dynamics.com/api/data/v8.2/$metadata#accounts","value":[
    {
      "@odata.etag":"W/\"646599\"","openrevenue_date":"2016-11-16T12:31:53Z","territorycode":1,"address2_freighttermscode":1,"address2_shippingmethodcode":1,"accountid":"9381b8b5-55a6-e611-80f9-1458d05a2ab0","statuscode":1,"creditonhold":false,"donotbulkemail":false,"donotsendmm":false,"createdon":"2016-11-09T08:22:54Z","statecode":0,"opendeals_state":1,"businesstypecode":1,"openrevenue_state":7,"_ownerid_value":"a8c706a9-29fd-4a91-bd8d-8f304cf141b5","donotbulkpostalmail":false,"name":"\\RBrMXmdTJ_juPepgBMbvHxS^s","donotemail":false,"donotphone":false,"donotpostalmail":false,"opendeals_date":"2016-11-16T12:31:53Z","versionnumber":646599,"address2_addresstypecode":1,"_modifiedby_value":"a8c706a9-29fd-4a91-bd8d-8f304cf141b5","shippingmethodcode":1,"followemail":true,"preferredcontactmethodcode":1,"_owningbusinessunit_value":"e5307675-2a9f-e611-80f8-c4346bc50748","_createdby_value":"a8c706a9-29fd-4a91-bd8d-8f304cf141b5","opendeals":0,"donotfax":false,"merged":false,"customersizecode":1,"marketingonly":false,"accountratingcode":1,"address2_addressid":"e93cd4bf-abcc-4198-8dbc-aa10d5f8cd06","_owninguser_value":"a8c706a9-29fd-4a91-bd8d-8f304cf141b5","modifiedon":"2016-11-09T08:32:39Z","participatesinworkflow":false,"accountclassificationcode":1,"address1_addressid":"e12d3c57-905c-4368-92ff-b5d13e3d5bc3","openrevenue":null,"lastusedincampaign":null,"address1_name":null,"address1_telephone2":null,"overriddencreatedon":null,"entityimageid":null,"ownershipcode":null,"creditlimit":null,"_primarycontactid_value":null,"address1_county":null,"entityimage_timestamp":null,"telephone3":null,"address1_freighttermscode":null,"address2_line1":null,"onholdtime":null,"_createdbyexternalparty_value":null,"telephone2":null,"primarysatoriid":null,"address2_telephone1":null,"address1_fax":null,"_createdonbehalfby_value":null,"address2_city":null,"address2_latitude":null,"address2_composite":null,"creditlimit_base":null,"int_facebook":null,"aging90_base":null,"address2_postalcode":null,"address2_name":null,"preferredappointmentdaycode":null,"_owningteam_value":null,"address2_line3":null,"revenue_base":null,"aging30":null,"ftpsiteurl":null,"_originatingleadid_value":null,"emailaddress3":null,"_modifiedbyexternalparty_value":null,"paymenttermscode":null,"websiteurl":null,"revenue":null,"address1_shippingmethodcode":null,"description":null,"tickersymbol":null,"lastonholdtime":null,"marketcap":null,"_parentaccountid_value":null,"_preferredsystemuserid_value":null,"address2_longitude":null,"_defaultpricelevelid_value":null,"address1_primarycontactname":null,"int_twitter":null,"accountcategorycode":null,"marketcap_base":null,"adx_modifiedbyusername":null,"address2_telephone3":null,"address2_postofficebox":null,"_preferredserviceid_value":null,"importsequencenumber":null,"address1_upszone":null,"stageid":null,"utcconversiontimezonecode":null,"aging60":null,"customertypecode":null,"telephone1":null,"address1_postofficebox":null,"_msa_managingpartnerid_value":null,"yominame":null,"address2_country":null,"address1_line2":null,"address1_postalcode":null,"traversedpath":null,"_transactioncurrencyid_value":null,"fax":null,"numberofemployees":null,"address2_upszone":null,"aging90":null,"address1_longitude":null,"emailaddress2":null,"address1_telephone1":null,"adx_modifiedbyipaddress":null,"exchangerate":null,"address1_stateorprovince":null,"address2_line2":null,"entityimage":null,"primarytwitterid":null,"timespentbymeonemailandmeetings":null,"accountnumber":null,"address1_line1":null,"_territoryid_value":null,"address1_composite":null,"_slaid_value":null,"address2_county":null,"_preferredequipmentid_value":null,"sic":null,"adx_createdbyusername":null,"entityimage_url":null,"processid":null,"address2_telephone2":null,"address1_addresstypecode":null,"address1_utcoffset":null,"address2_fax":null,"aging60_base":null,"address1_country":null,"_modifiedonbehalfby_value":null,"stockexchange":null,"address1_line3":null,"adx_createdbyipaddress":null,"aging30_base":null,"openrevenue_base":null,"sharesoutstanding":null,"_slainvokedid_value":null,"address1_city":null,"address2_primarycontactname":null,"address1_latitude":null,"_masterid_value":null,"address2_utcoffset":null,"emailaddress1":null,"timezoneruleversionnumber":null,"address2_stateorprovince":null,"preferredappointmenttimecode":null,"industrycode":null,"address1_telephone3":null
    },{
      "@odata.etag":"W/\"646591\"","openrevenue_date":"2016-11-16T12:31:53Z","territorycode":1,"address2_freighttermscode":1,"address2_shippingmethodcode":1,"accountid":"ca4a8f7a-51a6-e611-80fa-c4346bc562c4","statuscode":1,"creditonhold":false,"donotbulkemail":false,"donotsendmm":false,"createdon":"2016-11-09T07:52:37Z","statecode":0,"opendeals_state":1,"businesstypecode":1,"openrevenue_state":7,"_ownerid_value":"a8c706a9-29fd-4a91-bd8d-8f304cf141b5","donotbulkpostalmail":false,"name":"teWfvgYJZKvgYJu","donotemail":false,"donotphone":false,"donotpostalmail":false,"opendeals_date":"2016-11-16T12:31:53Z","versionnumber":646591,"address2_addresstypecode":1,"_modifiedby_value":"a8c706a9-29fd-4a91-bd8d-8f304cf141b5","shippingmethodcode":1,"followemail":true,"preferredcontactmethodcode":1,"_owningbusinessunit_value":"e5307675-2a9f-e611-80f8-c4346bc50748","_createdby_value":"a8c706a9-29fd-4a91-bd8d-8f304cf141b5","opendeals":0,"donotfax":false,"merged":false,"customersizecode":1,"marketingonly":false,"accountratingcode":1,"address2_addressid":"32184ac3-b065-46e7-a831-937c3494521f","_owninguser_value":"a8c706a9-29fd-4a91-bd8d-8f304cf141b5","modifiedon":"2016-11-09T08:32:39Z","participatesinworkflow":false,"accountclassificationcode":1,"address1_addressid":"34610224-62d5-42d9-ac70-51c498547a76","openrevenue":null,"lastusedincampaign":null,"address1_name":null,"address1_telephone2":null,"overriddencreatedon":null,"entityimageid":null,"ownershipcode":null,"creditlimit":null,"_primarycontactid_value":null,"address1_county":null,"entityimage_timestamp":null,"telephone3":null,"address1_freighttermscode":null,"address2_line1":null,"onholdtime":null,"_createdbyexternalparty_value":null,"telephone2":null,"primarysatoriid":null,"address2_telephone1":null,"address1_fax":null,"_createdonbehalfby_value":null,"address2_city":null,"address2_latitude":null,"address2_composite":null,"creditlimit_base":null,"int_facebook":null,"aging90_base":null,"address2_postalcode":null,"address2_name":null,"preferredappointmentdaycode":null,"_owningteam_value":null,"address2_line3":null,"revenue_base":null,"aging30":null,"ftpsiteurl":null,"_originatingleadid_value":null,"emailaddress3":null,"_modifiedbyexternalparty_value":null,"paymenttermscode":null,"websiteurl":null,"revenue":null,"address1_shippingmethodcode":null,"description":null,"tickersymbol":null,"lastonholdtime":null,"marketcap":null,"_parentaccountid_value":null,"_preferredsystemuserid_value":null,"address2_longitude":null,"_defaultpricelevelid_value":null,"address1_primarycontactname":null,"int_twitter":null,"accountcategorycode":null,"marketcap_base":null,"adx_modifiedbyusername":null,"address2_telephone3":null,"address2_postofficebox":null,"_preferredserviceid_value":null,"importsequencenumber":null,"address1_upszone":null,"stageid":null,"utcconversiontimezonecode":null,"aging60":null,"customertypecode":null,"telephone1":null,"address1_postofficebox":null,"_msa_managingpartnerid_value":null,"yominame":null,"address2_country":null,"address1_line2":null,"address1_postalcode":null,"traversedpath":null,"_transactioncurrencyid_value":null,"fax":null,"numberofemployees":null,"address2_upszone":null,"aging90":null,"address1_longitude":null,"emailaddress2":null,"address1_telephone1":null,"adx_modifiedbyipaddress":null,"exchangerate":null,"address1_stateorprovince":null,"address2_line2":null,"entityimage":null,"primarytwitterid":null,"timespentbymeonemailandmeetings":null,"accountnumber":null,"address1_line1":null,"_territoryid_value":null,"address1_composite":null,"_slaid_value":null,"address2_county":null,"_preferredequipmentid_value":null,"sic":null,"adx_createdbyusername":null,"entityimage_url":null,"processid":null,"address2_telephone2":null,"address1_addresstypecode":null,"address1_utcoffset":null,"address2_fax":null,"aging60_base":null,"address1_country":null,"_modifiedonbehalfby_value":null,"stockexchange":null,"address1_line3":null,"adx_createdbyipaddress":null,"aging30_base":null,"openrevenue_base":null,"sharesoutstanding":null,"_slainvokedid_value":null,"address1_city":null,"address2_primarycontactname":null,"address1_latitude":null,"_masterid_value":null,"address2_utcoffset":null,"emailaddress1":null,"timezoneruleversionnumber":null,"address2_stateorprovince":null,"preferredappointmenttimecode":null,"industrycode":null,"address1_telephone3":null
    },{
      "@odata.etag":"W/\"646593\"","openrevenue_date":"2016-11-16T12:31:53Z","territorycode":1,"address2_freighttermscode":1,"address2_shippingmethodcode":1,"accountid":"d69eb9b1-52a6-e611-80fa-c4346bc562c4","statuscode":1,"creditonhold":false,"donotbulkemail":false,"donotsendmm":false,"createdon":"2016-11-09T08:01:19Z","statecode":0,"opendeals_state":1,"businesstypecode":1,"openrevenue_state":7,"_ownerid_value":"a8c706a9-29fd-4a91-bd8d-8f304cf141b5","donotbulkpostalmail":false,"name":"LwhZKvgYKugXeW","donotemail":false,"donotphone":false,"donotpostalmail":false,"opendeals_date":"2016-11-16T12:31:53Z","versionnumber":646593,"address2_addresstypecode":1,"_modifiedby_value":"a8c706a9-29fd-4a91-bd8d-8f304cf141b5","shippingmethodcode":1,"followemail":true,"preferredcontactmethodcode":1,"_owningbusinessunit_value":"e5307675-2a9f-e611-80f8-c4346bc50748","_createdby_value":"a8c706a9-29fd-4a91-bd8d-8f304cf141b5","opendeals":0,"donotfax":false,"merged":false,"customersizecode":1,"marketingonly":false,"accountratingcode":1,"address2_addressid":"135e6464-a04a-4e2f-8ee7-de1088f6b2fc","_owninguser_value":"a8c706a9-29fd-4a91-bd8d-8f304cf141b5","modifiedon":"2016-11-09T08:32:39Z","participatesinworkflow":false,"accountclassificationcode":1,"address1_addressid":"2ec27dc6-e50b-4043-b1fe-126f7baf2150","openrevenue":null,"lastusedincampaign":null,"address1_name":null,"address1_telephone2":null,"overriddencreatedon":null,"entityimageid":null,"ownershipcode":null,"creditlimit":null,"_primarycontactid_value":null,"address1_county":null,"entityimage_timestamp":null,"telephone3":null,"address1_freighttermscode":null,"address2_line1":null,"onholdtime":null,"_createdbyexternalparty_value":null,"telephone2":null,"primarysatoriid":null,"address2_telephone1":null,"address1_fax":null,"_createdonbehalfby_value":null,"address2_city":null,"address2_latitude":null,"address2_composite":null,"creditlimit_base":null,"int_facebook":null,"aging90_base":null,"address2_postalcode":null,"address2_name":null,"preferredappointmentdaycode":null,"_owningteam_value":null,"address2_line3":null,"revenue_base":null,"aging30":null,"ftpsiteurl":null,"_originatingleadid_value":null,"emailaddress3":null,"_modifiedbyexternalparty_value":null,"paymenttermscode":null,"websiteurl":null,"revenue":null,"address1_shippingmethodcode":null,"description":null,"tickersymbol":null,"lastonholdtime":null,"marketcap":null,"_parentaccountid_value":null,"_preferredsystemuserid_value":null,"address2_longitude":null,"_defaultpricelevelid_value":null,"address1_primarycontactname":null,"int_twitter":null,"accountcategorycode":null,"marketcap_base":null,"adx_modifiedbyusername":null,"address2_telephone3":null,"address2_postofficebox":null,"_preferredserviceid_value":null,"importsequencenumber":null,"address1_upszone":null,"stageid":null,"utcconversiontimezonecode":null,"aging60":null,"customertypecode":null,"telephone1":null,"address1_postofficebox":null,"_msa_managingpartnerid_value":null,"yominame":null,"address2_country":null,"address1_line2":null,"address1_postalcode":null,"traversedpath":null,"_transactioncurrencyid_value":null,"fax":null,"numberofemployees":null,"addr

使用这种方式批量执行脚本的缺陷是我们需要自己去解析返回的报文,这可能需要我们花费不少功夫。

时间: 11-15

Dynamics CRM 2015/2016/365 Web API:批处理任务的相关文章

Dynamics CRM 2015/2016/365 Web API:用户模拟

今天再更新一篇关于在Web API接口中使用用户模拟这一功能,用户模拟在Dynamics CRM开发中已经不是新概念了,历任接口都支持这个功能.在介绍怎么在Web API中使用该功能之前,我们先来过一遍用户模拟的具体功能. 用户模拟,顾名思义,即为模拟其他用户.在调用接口的时候如果我们都需要提供一个账号密码信息,但是很多时候,我们的接口的认证信息是一个集成账号,但是我们却希望通过这个接口创建的记录的创建者是其它用户.如果你有这个需求,你就需要用到用户模拟功能. 在Dynamics CRM Web

Dynamics CRM 2015/2016/365 Web API:级联查询

级联查询,即为在一次查询请求中吧父子记录统统查询出来的行为.使用Web API进行这样的查询非常的方便,主需要在OData Query URL中加入$expand关键字即可,不管在轻客户端或重客户端,调用都非常的方便. 我们来看一个使用级联查询的Query URL实例: GET https://crmhomedev06.api.crm6.dynamics.com/api/data/v8.2/accounts(79309b7b-8bac-e611-80f9-1458d05a2ab0)?$expan

Dynamics CRM 2015/2016/365 Web API:级联创建

级联创建,即为在创建主记录的同时,可以把与其相关联的新记录也一并进行创建.举个例子,我们在创建客户记录的后,一般需要在创建一个联系人记录,然后将联系人记录设置为该客户记录的主要联系人. 在上面这个例子中,如果我们用传统的方式去做,需要向服务器请求3次,才能完成,如果涉及的相关记录数据繁多,那么请求的次数也需要增加.但是如果我们使用Web API的级联创建功能,我们只需向服务器发起一次请求即可. 级联创建和普通创建的请求方式一致,唯一的区别在于怎么去构造要记录创建对象.我们继续使用上面这个例子,我

Dynamics CRM 2015/2016 Web API:基于视图的数据查询

Dynamics CRM 2016 Web API支持基于视图来查询数据,博主初看到该Feature,着实让我眼前一亮,这个功能太给力了,完全颠覆了之前复杂繁琐的取数方式了,现在的视图真正到了定义一次,处处复用的地步了!使用方法也很简单,只需要加个参数并指定需要调用的View ID就好了.接下来我给大家演示3个比较常用的场景:调用公共视图,调用私有视图,调用SubGrid视图. 公共视图 什么是公共视图?就是大家都有权限访问的视图,比如客户实体上的我的可用客户视图,我们一般在UI上面这么调用它们

Dynamics CRM 2015/2016 Web API:注册 APP(调用CRM Online Web API)

在之前的三篇文章中,博主提到过Web API将会成为Dynamics CRM 的主流编程接口,所以它的重要性是不言而喻的.那今天,我们来看看调用CRM Online Web API之前需要做些什么准备工作,之前的博文并没有介绍这步,今天给大家补上.在后续的一段时间呢,我会写篇怎么在重客户端调用Dynamics CRM On Premise版本的Web API. 在调用Dynamics CRM Online Web API之前呢,我们需要创建一个与其关联的AD环境,创建方式很简单:在Office

Dynamics CRM 2015/2016 Web API:Unbound Function 和 Bound Function

今天我们来看看Dynamics CRM Web API Function 吧, 这是一个新概念,刚接触的时候我也是比较的迷糊,这样的命名确实是和之前的那套基于SOAP协议的API完全联系不上.好了,不说闲话了.这里的Function呢,就我来看,更像是一些被封装好的原生函数和老API中的Request差不多的意思,只是API的架构方式变了,所以名称也就跟着变了. 我们之前要查看当前登录用户的信息,需要调用WhoAmIRequest,那现在呢?我们需要调用WhoAmI Function. 这里的F

Dynamics CRM 2015/2016 Web API:聚合查询

各位小伙伴们,今天是博主2016年发的第一篇文章,首先祝大家新年快乐,工资Double,哈哈.今天我们来看一个比较重要的Feature--使用Web API执行FetchXML查询!对的,各位,你们没有听错,使用Web API执行FetchXML查询.在过去我们做这样的事情可是要花九牛二虎之力哟,拼接大量的SOAP消息体而且还容易出错.现在好了,我们自己可以在URL里面加上我们想要执行的FetchXML即可,系统则会乖乖的把我们想要的数据返回回来,是不是很美好呢! 言归正传,Web API的数据

Dynamics CRM 2015/2016 Web API:Unbound Custom Action 和 Bound Custom Action

今天我们再来看看Bound/Unbound Custom Action吧,什么是Custom Action?不知道的小伙伴们就out了,Dynamics CRM 2013就有了这个功能啦.和WhoAmI这类消息一样,我们都可以通过代码去调用它们,只不过呢,今天我要给大家讲讲怎么用Web API的方式去调用它们. Custom Action也被划分为Bound和Unbound两种类型了,它们的具体含义和之前讲的Function和Action没有区别,唯一的区别就是,这里的Custom Action

Dynamics CRM 2015/2016 Web API:Unbound Action 和 Bound Action

上篇文章介绍了Bound/Unbound Function,今天我们来看看Action吧,像我之前说的:Function和Action之前的区别可以简单理解为,Function不修改数据,但是Action却会修改数据. 今天呢,我们也分别看看Bound Action和Unbound Action,其实它们的调用方式和Function是一样的,只是这里的请求提交方式更多的是采用Post的方式,我们先来看两个例子吧: 公共变量 static string clientId = "580c20be-5