Odata v4 error "Does not support untyped value in non-open type"

When I updated the model, it throws "Does not support untyped value in non-open form." It worked before the update. Failed to determine the source of the problem. any ideas.

+12
source share
1 answer

I already encountered this error, and it was caused by passing a property of a JSON object that is not in the data model.

For example, given a data model:

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

    public string UserName { get; set; }
}

And the OData controller has a method:

public IHttpActionResult Post(User user)

When the following data is sent using the method POST:

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

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, .

+17

Source: https://habr.com/ru/post/1684709/


All Articles