-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple.OData.Client is unable to invoke Action that accepts entity collection #117
Comments
Thanks for reporting the issue.
|
I have now used Simple.OData.Client v 4.7.1 but getting the same error. The service metadata is as follows: http://localhost:55225/Service/$metadata
|
I will appreciate sample solution, it will be easier to reproduce the problem. Can you send it to me at vagif.abilov@gmail.com? |
I managed to reproduce the issue. Expect the fix soon :-) |
The new version 4.7.2 has fixed the issue for me. Thanks for prompt support! |
I get error "The parameter 'wheels' is of Edm type kind 'Collection'. You cannot call CreateCollectionWriter on a parameter that is not of Edm type kind 'Collection'."
Below are details of my setup:
Web API 2.2 OData v4 service : I have defined Action in WheelsController class in my service like this:
public async Task< IHttpActionResult > UpdateWheels(ODataActionParameters parameters)
{
object value;
parameters.TryGetValue("carId", out value);
int carId= (int)value;
parameters.TryGetValue("wheels", out value)
IEnumerable< Wheel > wheels = (IEnumerable< Wheel >)value;
// logic goes here....
return OK();
}
In WebApiConfig.cs files, the Action configuration is defined as below:
ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet< Car >("Cars");
builder.EntitySet< Wheel >("Wheels");
var action = builder.EntityType < Wheel > ().Collection.Action("UpdateWheels");
action.Parameter< int >("carId");
action.CollectionParameter< Wheel >("wheels");
I get success in invoking the above action from RESTClient extenstion in FireFox browser as POST request to URL "http://localhost/Service/Wheels/UpdateWheels" with Request Body as
{"carId":2,
"wheels":[{"Id":1,"Name":"Wheel Front 1","Description":"Front wheel left", "PositionEnum":"FrontLeft"},{"Id":2,"Name":"Wheel Front 2","Description":"Front wheel right", "PositionEnum":"FrontRight"}]
}
However, it gives error when I try to invoke the above service action using Simple.OData.Client in client application such as
public async void TestUpdateWheels(List< Wheel > wheelList)
{
// client is derived from ODataClient from assembly Simple.OData.Client.Core.dll, v4.3.0.0
await client.For< Wheel >()
.Action("UpdateWheels")
.Set(new { carId = 2, wheels = wheelList})
.ExecuteAsync();
}
It gives error message: The parameter 'wheels' is of Edm type kind 'Collection'. You cannot call CreateCollectionWriter on a parameter that is not of Edm type kind 'Collection'.
How can I call successfully the above Action from ODataClient? Please help.
The text was updated successfully, but these errors were encountered: