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.
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:
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.
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.
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" }]
But if I POST the above body with this new “Values” property value I get the error:
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.
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: "296e5e0a-ffe1-e944-80f4-005166811dbb"
)? – jasonscriptAn unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartArray' node was expected.
. – Francis Gagnon"Values": [ {"Value":"myGuid" } ]
I get a different error: "No parameterless constructor defined for this object" – jasonscript