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.