zoukankan      html  css  js  c++  java
  • 解决Dynamics 365使用JS调用Web API时报no property value was found in the payload 错误。

    我是微软Dynamcis 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面的微软最有价值专家(Microsoft MVP),欢迎关注我的微信公众号 MSFTDynamics365erLuoYong ,回复323或者20190421可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!

    使用Web API插入Dynamcis 365 Customer Engagement实体记录时碰到如下报错:

    1. message: "An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'new_returnrequest' which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values. ↵ at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadUndeclaredProperty(IODataJsonLightReaderResourceState resourceState, String propertyName, Boolean propertyWithValue) ↵ at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadPropertyWithoutValue(IODataJsonLightReaderResourceState resourceState, String propertyName) ↵ at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.<>c__DisplayClass4_0.<ReadResourceContent>b__0(PropertyParsingResult propertyParsingResult, String propertyName) ↵ at Microsoft.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(PropertyAndAnnotationCollector propertyAndAnnotationCollector, Func`2 readPropertyAnnotationValue, Action`2 handleProperty) ↵ at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadResourceContent(IODataJsonLightReaderResourceState resourceState) ↵ at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadResourceStart(PropertyAndAnnotationCollector propertyAndAnnotationCollector, SelectedPropertiesNode selectedProperties) ↵ at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadAtStartImplementationSynchronously(PropertyAndAnnotationCollector propertyAndAnnotationCollector) ↵ at Microsoft.OData.ODataReaderCore.ReadImplementation() ↵ at Microsoft.OData.ODataReaderCore.InterceptException[T](Func`1 action) ↵ at System.Web.OData.Formatter.Deserialization.ODataReaderExtensions.ReadResourceOrResourceSet(ODataReader reader) ↵ at System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext) ↵ at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)"
    2. stacktrace: " at Microsoft.Crm.Extensibility.OData.CrmODataUtilities.ValidateInputParameters(ModelStateDictionary controllerModelState) ↵ at Microsoft.Crm.Extensibility.OData.EntityController.PostEntitySetImplementation(String& entitySetName, EdmEntityObject entityObject) ↵ at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties) ↵ at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func) ↵ at lambda_method(Closure , Object , Object[] ) ↵ at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters) ↵ at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken) ↵--- End of stack trace from previous location where exception was thrown --- ↵ at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() ↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) ↵ at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext() ↵--- End of stack trace from previous location where exception was thrown --- ↵ at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() ↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) ↵ at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext() ↵--- End of stack trace from previous location where exception was thrown --- ↵ at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() ↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) ↵ at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
    3. type: "Microsoft.Crm.CrmHttpException"

    很可能是为查找字段赋值有问题,这么排查,下面是一个正确示例

    "new_ReturnRequest@odata.bind": "/systemusers(" + entityid.replace("{", "").replace("}", "") + ")"

    1. 属性名称要加上 @data.bind

    2.属性名称中的字段名要用架构名称,而不是和其他字段一样用逻辑名称

    3.值以 / 开头

    4 值中 / 后面是实体逻辑名称加上 s 或者es,具体查看实体的元数据

    5. 值中的guid不要包括 { 和 }

    6. 值中的guid要用 ( 和 ) 包含起来

    7. 对于Customer类型的字段,是特别写法,需要查看元数据来确认,可以参考我以前博文。

    8. 如果前面方法都不好用,可以尝试用MetadataBrowser解决方案查看该实体的元数据,找到这个字段对应的N:1关系的 ReferencingEntityNavigationPropertyName 这个值作为 @data.bind 的前面部分。

    还有可能就是你新增记录的时候实体名字写错了,写成别的实体名字了,某些属性在这个别的实体中不存在,改过来就好。

    Account实体的Parent Account字段请用parentaccountid@odata.bind ,Primary Contact请用 primarycontactid@odata.bind 属性来赋值。

  • 相关阅读:
    C语言资料分享
    vue子组件添加事件无效解决
    vue-cli3 vue动画 打包后不生效解决
    setTimeOut定时器实现数组内容循环获取
    echart 之仪表盘 动态分段颜色实现
    elementUI table树默认箭头修改
    《二》打包发布工程-README.md编辑
    《一》打包发布工程--npm 打包发布js库篇
    npm打包发布js库包npm ERR! 403 Forbidden
    安装nrm 后执行报错TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string
  • 原文地址:https://www.cnblogs.com/luoyong0201/p/Dynamics_365_no_property_value_was_found_in_the_payload.html
Copyright © 2011-2022 走看看