无法从 Microsoft Dynamics CRM WebAPI 调用 BulkDelete 操作 [英] Unable to call the BulkDelete action from Microsoft Dynamics CRM WebAPI

查看:89
本文介绍了无法从 Microsoft Dynamics CRM WebAPI 调用 BulkDelete 操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调用 BulkDelete() 操作本地 Microsoft Dynamics CRM 365 (2016/v8.2) 实例的 WebAPI(OData REST 服务).

I’m trying to call the BulkDelete() Action of the WebAPI (OData REST service) of an on premise Microsoft Dynamics CRM 365 (2016 / v8.2) instance.

目前我仍处于尝试使用 Postman 使操作起作用的阶段.我正在对类似于 https://MY_CRM_SERVER/api/data/v8.2/BulkDelete() 的 URL 执行 HTTP POST,其正文如下:

For now I am still at the stage of trying to make the action work by using Postman. I am doing an HTTP POST to a URL similar to https://MY_CRM_SERVER/api/data/v8.2/BulkDelete() with the following body:

{
    JobName: "Test Bulk Delete 1",
    QuerySet: [{
        EntityName: "oo_thingstodelete",
        ColumnSet: {
            AllColumns: true
        },
        Distinct: false,
        Criteria: {
            FilterOperator: "And",
            Conditions: [{
                AttributeName: "oo_thingstodeleteid",
                Operator: "Equal",
                Values: [ "296e5e0a-ffe1-e944-80f4-005166811dbb" ]
            }]
        }
    }],
    StartDateTime: "2019-04-18T05:00:00Z",
    ToRecipients: [],
    CCRecipients: [],
    SendEmailNotification: false,
    RecurrencePattern: "",
    RunNow: true
}

此请求正文当前产生错误:

This request body currently yields the error:

名称为 '' 的属性被发现具有类型为值的节点'原始值';然而,一个复杂的类型值应为Microsoft.Dynamics.CRM.Object".

The property with name '' was found with a value node of type 'PrimitiveValue'; however, a complex value of type 'Microsoft.Dynamics.CRM.Object' was expected.

据我所知,这是因为Values"属性(在 QuerySet/Criteria/Conditions 下)需要Object ComplexType"的集合.这记录在 CRM WebAPI v8 的ConditionExpression"页面.

From what I can tell, this is because the "Values" property (under QuerySet / Criteria / Conditions) expects a collection of "Object ComplexType". This is documented in the "ConditionExpression" page of the CRM WebAPI v8.

此时我假设Values"属性需要被赋予一个类似于以下的值(而不是一个简单的字符串值):

At this point I am assuming that the "Values" property needs to be given a value similar to the following (instead of a simple string value):

Values: [ {  "Value": "296e5e0a-ffe1-e944-80f4-005166811dbb" }]

但是如果我用这个新的Values"属性值发布上面的正文,我会得到错误:

But if I POST the above body with this new "Values" property value I get the error:

类型上不存在属性值"'Microsoft.Dynamics.CRM.Object'.确保只使用属性名称由类型定义.

The property 'Value' does not exist on type 'Microsoft.Dynamics.CRM.Object'. Make sure to only use property names that are defined by the type.

这感觉像是进步,但它并没有告诉我应该使用什么属性名称来代替.CRM WebAPI Object ComplexType"的文档 没有列出我可以在这个对象中使用的任何属性名称,我也没有找到任何关于如何通过 WebAPI 使用 BulkDelete 操作的示例代码.

This feels like progress but it doesn’t tell me what property name I should be using instead. The CRM WebAPI documentation for the "Object ComplexType" doesn’t list any property names that I can use in this object and I haven’t found any sample code on how to use the BulkDelete action via WebAPI.

请注意,此请求正文可能存在其他问题.这只是我目前的障碍.

Note that there may be other issues with this request body. This is just my current roadblock.

推荐答案

对我有用的是明确指定 values 数组中项目的类型.即:

What worked for me was to specify type of item in values array explicitly. I.E.:

Values: [{"Value":"296e5e0a-ffe1-e944-80f4-005166811dbb","Type":"System.Guid"}]

我有不同版本的 CRM (9.1).

I have different version of CRM though (9.1).

这篇关于无法从 Microsoft Dynamics CRM WebAPI 调用 BulkDelete 操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆