Dynamics CRM Web API Add Marketing List to Campaign ""Association cannot be performed between an entity of type campaign and an entity of type list.""

1

I am getting the error, "Association cannot be performed between an entity of type campaign and an entity of type list." when I try to use Dynamics CRM Online Web API to make a connection between a Campaign and a Marketing List.

I am using V9.0 of the api

Approach 1: deep insert

POST: {{webapiurl}}campaigns

Body:

 {
    "name": "test 2",

    "campaignlist_association": [

    {
        "listname":"test3", 
        "createdfromcode":2
    }

]

}

Response: {

"error": { "code": "0x80040203",

"message": "Association cannot be performed between an entity of type campaign and an entity of type list.", "innererror": { "message": "Association cannot be performed between an entity of type campaign and an entity of type list.", "type": "Microsoft.Dynamics.Solution.Common.CrmNotSupportedException", } } }

Approach 2: Association POST: …/campaigns(000000000xxxxxx)/campaignlist_association/$ref

Body:

{  
"@odata.id":"{{webapiurl}}/lists(11111111xxxxxxxx)"  
}

Response:

{ "error": { "code": "0x80040203",

"message": "Association cannot be performed between an entity of type campaign and an entity of type list.",

"innererror": { "message": "Association cannot be performed between an entity of type campaign and an entity of type list.", "type": "Microsoft.Dynamics.Solution.Common.CrmNotSupportedException", } } }

Results Both approaches yield the same error message: "Association cannot be performed between an entity of type campaign and an entity of type list." However, when if I relate them in the Dynamics CRM UI, and query campaigns I accurately see the list assigned to the campaign if I expand the "campaignlist_association" property via the web api.

dynamics-crm
microsoft-dynamics
dynamics-crm-webapi
asked on Stack Overflow Apr 9, 2019 by ICS

1 Answer

1

Many native N-N relationships require an action to be called instead of an association POST request to associate multiple records. You can check the available out of the box Web API actions list here

In your case in specific you need to call Microsoft.Dynamics.CRM.AddItemCampaign action in a POST request like this:

URL:

[Organization URI]/lists(YourMarketingListGUID)/Microsoft.Dynamics.CRM.AddItemCampaign

Body:

{
    "Campaign": {
        "campaignid": "YourCampaignGUID"
    }
}
answered on Stack Overflow Apr 9, 2019 by André Cavaca • edited Apr 9, 2019 by André Cavaca

User contributions licensed under CC BY-SA 3.0