Microsoft 365 API : Issue at attaching Contact to Campaign Response

被刻印的时光 ゝ 提交于 2021-02-10 22:13:50

问题


I am trying to attach a contact to campaign response.

I am using rest API for that.

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/campaignresponse?view=dynamics-ce-odata-9

Post Data :

{
  "firstname": "TestFirst",
  "lastname": "TestLast",
  "emailaddress": "test@test.com",
  "telephone": "1234567890",
  "prioritycode": 0,
  "responsecode": 1,
  "subject": "Test Subject",
  "statuscode": 1,
  "regardingobjectid_campaign@odata.bind": "/campaigns(xxxx90c-11ef-e811-a966-000d3ad24a0d)",
  "regardingobjectid_contact@odata.bind": "/contacts(xxxxfa2e-c3b5-e811-a962-000d3ad24a0d)"
}

Here is my JSON.

I am getting Error : “Campaign as RegardingObject must be supplied”. Without contact, it works fine.


回答1:


I had the same problem and the documentation is not very clear about it, I had to check all the relationships of the CampaignResponse in order to understand how to solve this.

If you want to create a CampaignResponse linked to both a Campaign and a Contact you need to do the following:

  • Create a CampaignResponse with the "regardingobjectid_campaign@odata.bind" in the params sent.

POST "https://some_subdomain.crm6.dynamics.com/api/data/v9.0/campaignresponses"
    {
      "regardingobjectid_campaign@odata.bind": "/campaigns(CAMPAIGN_ID_HERE)",
      "description": "some desc",
      "subject": "some subject "
    }
  • Then find the CampaignResponse you just created to get its activityid (every CampaignResponse is an Activity)
  • Finally, you need to create a new ActivityParty, that will link the Contact to the CampaignResponse.

POST "https://some_subdomain.crm6.dynamics.com/api/data/v9.0/campaignresponses(CAMPAIGN_ID_HERE)/activitypointer_activity_parties"
{
  "partyid_contact@odata.bind": "/contacts(CONTACT_ID_HERE)",
  "participationtypemask": 11 //this is the code for customers
}



回答2:


The "Regarding" lookup field can only be set to a single "regarding" record. Even though it appears that there are different Regarding fields, one for each entity type, those are "helper" fields that let you easily set the main Regarding field by setting one of those regardingobjectid_xxx fields.

You must choose to use either a campaign or a contact as your Regarding field. You can of course create other lookups, so you could use the Regarding field for your campaign and then add an additional Contact lookup field, for example.



来源:https://stackoverflow.com/questions/53516798/microsoft-365-api-issue-at-attaching-contact-to-campaign-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!