Odata v4错误“不支持非开放类型的非类型值" [英] Odata v4 error "Does not support untyped value in non-open type"

查看:255
本文介绍了Odata v4错误“不支持非开放类型的非类型值"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我更新模型时,它抛出不支持非开放类型的无类型值".在更新之前它正在工作.无法确定问题的根源. 有任何想法吗.

As I updated the model, it throws "Does not support untyped value in non-open type". It was working before the update. Unable to pin down the source of the problem. any ideas.

推荐答案

我以前遇到过此错误,它是由于传递了数据模型中不存在的JSON对象的属性引起的.

I've experienced this error before and it's caused by passing a property of a JSON object that doesn't exist on the data model.

例如,给定数据模型:

public class User
{
    public long UserId { get; set; }

    public string UserName { get; set; }
}

OData控制器具有以下方法:

And an OData controller has the method:

public IHttpActionResult Post(User user)

使用POST方法发送以下数据时:

When the following data is sent using the POST method:

{
    "UserId": "0",
    "UserName": "test",
    "UserPassword": "test"
}

然后服务器将返回错误400,并显示以下响应:

Then the server will return error 400 with the following response:

{
    "error": {
        "code": "",
        "message": "The request is invalid.",
        "innererror": {
            "message": "user : Does not support untyped value in non-open type.\r\n",
            "type": "",
            "stacktrace": ""
        }
    }
}

因此,如果在本例中,将UserPassword属性从使用POST方法发送的数据中删除,则不会发生该错误.

So if the UserPassword property, in this example, is removed from the data sent using the POST method, then the error doesn't occur.

这篇关于Odata v4错误“不支持非开放类型的非类型值"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆