Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Need help with creating a relationship between Lead and Campaign Activity entities

Posted on by 5

Hi All,

I'm working on a request for a customer to have a new lead created in D365 when a client calls in to their contact center.  They want the lead populated with the client's phone number, as well as the campaign and campaign activity associated to the toll-free number (done via a custom entity they created).

I'm able to make HTTP requests to the Web API and pull down all the data I need, but when I go to make the POST request to create the lead I'm getting an HTTP 400 error.  Something is off with the @odata.bind I'm using to associate the new lead with the campaign activity, and I'm not sure how to resolve it.  

Testing in Postman, I'm sending a POST request to the below URL

customer.crm.dynamics.com/.../leads

Along with the following JSON payload

{"telephone1":"(555) 555-2900","campaignid@odata.bind":"/campaigns(ecba2265-b477-e311-96a4-005056ba0cf6)","_sh_campaignactivity_value@odata.bind":"/campaignactivities(3dc7437d-8f4a-ed11-bba1-00224828933c)"}
I get the following HTTP 400 error in response:
{
"error": {
"code": "0x0",
"message": "Error identified in Payload provided by the user for Entity :'leads', For more information on this error please follow this help link go.microsoft.com/.../ ----> InnerException : Microsoft.OData.ODataException: A property '_sh_campaignactivity_value' which only has property annotations in the payload but no property value is declared to be of type 'Edm.Guid'. In OData, only navigation properties and named streams can be represented as properties without values.\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadPropertyWithoutValue(IODataJsonLightReaderResourceState resourceState, String propertyName)\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.<>c__DisplayClass9_0.<ReadResourceContent>b__0(PropertyParsingResult propertyParsingResult, String propertyName)\r\n at Microsoft.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(PropertyAndAnnotationCollector propertyAndAnnotationCollector, Func`2 readPropertyAnnotationValue, Action`2 handleProperty)\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadResourceContent(IODataJsonLightReaderResourceState resourceState)\r\n at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadNextNestedInfo()\r\n at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadAtNestedResourceInfoEndImplementation()\r\n at Microsoft.OData.ODataReaderCore.ReadImplementation()\r\n at Microsoft.OData.ODataReaderCore.InterceptException[T](Func`1 action)\r\n at System.Web.OData.Formatter.Deserialization.ODataReaderExtensions.ReadResourceOrResourceSet(ODataReader reader)\r\n at System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)\r\n at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)."
}
}
 
I'm guessing this has something to do with the fact that the property I'm trying to associate is _sh_campaignactivity_value on one end, and activityid on the other, but I can't find any other properties to use to accomplish this.  Can someone help point me in the right direction?  This is holding up a project to migrate this contact center to a cloud-based platform.
Let me know if any additional info is needed.  Thanks in advance.
  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: Need help with creating a relationship between Lead and Campaign Activity entities

    Hi CJ220,

    Hm... This is the concern which I raised in my last answer.

    If I answer your question then please mark it as verified.

    Let me know if I can provide you with more details.

    Thanks
    Regards,

    Abdul Wahab
    Power Platform & Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: www.linkedin.com/.../

  • Suggested answer
    CJ220 Profile Picture
    CJ220 5 on at
    RE: Need help with creating a relationship between Lead and Campaign Activity entities

    After more experimentation I was able to resolve the issue.  

    The logical name for the activity id in the Leads entity is _sh_campaignactivity_value.  To use @odata.bind on this property, it needs to be set as sh_CampaignActivity.  Once I made this small change the POST request is completing successfully.

    Screen-Shot-2022_2D00_10_2D00_16-at-12.09.52-AM.png

  • CJ220 Profile Picture
    CJ220 5 on at
    RE: Need help with creating a relationship between Lead and Campaign Activity entities

    Hi Abdual,

    Thanks for the reply and the additional information.  How would I use these relationships in my POST request then to populate the new lead with the activityid?

    I tried using the name in the screenshot you provided and I'm getting the same error.

    Thanks

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: Need help with creating a relationship between Lead and Campaign Activity entities

    Hi CJ220,

    Campaign and Campaign Activity tables are having an out-of-the-box relationship with the lead table. I do not think so we need a new relationship here.

    pastedimage1665802093336v1.png

    Usually, the Navigation property is equal to Schema Name. 

    Is _sh_campaignactivity_value the schema name of this column? I do not think so.

    If I answer your question then please mark it as verified.

    Let me know if I can provide you with more details.

    Thanks
    Regards,

    Abdul Wahab
    Power Platform & Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: www.linkedin.com/.../

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans