使用 Azure LogicApps 在 Dynamics 365 连接的现场服务中创建新记录



我正在尝试在 Dynamics 365 连接的现场服务中创建一条新记录。我在流分析中创建了一个查询,用于将设备数据发送到队列。

例如,在 Azure LogicApps 中,有效负载消息如下所示

{"Device":"ESP8266","AccValue":21168,"Location":"$GPRMC ..."}

此消息使用 parseJSON 解析,以便我可以从有效负载中提取每个字段。在下一个函数中创建新记录,我可以简单地将 AccValue 和位置用于"描述"列。但是,当我尝试将设备参数设置为设备时,出现此错误:

{
"status":
400,

"message":
"An error occurred while validating input parameters: Microsoft.OData.ODataException: A 'PrimitiveValue' node with non-null value was found when trying to read the value of the property 'msdyn_Device'; however, a 'StartArray'
 node, a 'StartObject' node, or a 'PrimitiveValue' node with null value was expected.rn at Microsoft.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ValidateExpandedNestedResourceInfoPropertyValue(IJsonReader jsonReader, Nullable`1 isCollection,
 String propertyName)rn at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadPropertyWithValue(IODataJsonLightReaderResourceState resourceState, String propertyName, Boolean isDeltaResourceSet)rn at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.<>c__DisplayClass9_0.<ReadResourceContent>b__0(PropertyParsingResult
 propertyParsingResult, String propertyName)rn at Microsoft.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(PropertyAndAnnotationCollector propertyAndAnnotationCollector, Func`2 readPropertyAnnotationValue, Action`2 handleProperty)rn at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadResourceContent(IODataJsonLightReaderResourceState
 resourceState)rn at Microsoft.OData.JsonLight.ODataJsonLightReader.StartReadingResource()rn at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadAtStartImplementationSynchronously(PropertyAndAnnotationCollector propertyAndAnnotationCollector)rn at Microsoft.OData.ODataReaderCore.ReadImplementation()rn
 at Microsoft.OData.ODataReaderCore.InterceptException[T](Func`1 action)rn at System.Web.OData.Formatter.Deserialization.ODataReaderExtensions.ReadResourceOrResourceSet(ODataReader reader)rn at System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.Read(ODataMessageReader
 messageReader, Type type, ODataDeserializerContext readContext)rn at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)",

"source":
"x.crm4.dynamics.com",
"errors": [],
"debugInfo":
"clientRequestId: 03d448c2-e6fe-4bac-b6c4-19328bc2b1bb"
}

如果我省略"设备"参数,则 D365 CFS 中列出了 IoT 警报:

设备及其信息应该是新创建的记录,其中包含 GPS 和 AccValue 列的"说明"和 Dynamics 365 连接现场服务中"设备"列的设备名称 (ESP8266(。它已注册到 IoT 中心并正确发送数据。

解决这个问题

的方法是什么?

当您在 CDS 中具有导航属性(关系(并尝试向其发送基元值(整数、字符串等(时,会发生此错误。它需要一个实体或实体数组。

您需要根据其相应的定义交叉检查要发送的有效负载中的属性值。要发送的一个或多个属性是针对关系的,并且具有不正确的值。

"消息":"验证输入参数时出错:Microsoft.OData.OData异常:尝试读取属性'msdyn_Device'的值时发现具有非空值的'PrimitiveValue'节点;但是,需要具有空值的"起始阵列"节点、"启动对象"节点或"基元值"节点。\r 在

最新更新