asp.net web api2 - Simple.OData.Client - Unable to invoke Action that accepts entity collection parameter -
i error "the parameter 'wheels' of edm type kind 'collection'. cannot call createcollectionwriter on parameter not of edm type kind 'collection'."
below details of setup:
web api 2.2 odata v4 service : have defined action in wheelscontroller class in service 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, action configuration defined 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 success in invoking above action restclient extenstion in firefox browser post request url "http://localhost/service/wheels/updatewheels" request body
{"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, gives error when try invoke above service action using simple.odata.client in client application such
public async void testupdatewheels(list<wheel> wheellist) { // client derived odataclient assembly simple.odata.client.core.dll, v4.3.0.0 await client.for<wheel>() .action("updatewheels") .set(new { carid = 2, wheels = wheellist}) .executeasync(); } error message: parameter 'wheels' of edm type kind 'collection'. cannot call createcollectionwriter on parameter not of edm type kind 'collection'.
how can call above action odataclient?
this turn out bug in simple.odata.client version 4.3.0 when reported project site. details, visit link https://github.com/object/simple.odata.client/issues/117
the new bug fix version 4.7.2 of simple.odata.client has fixed issue me!
Comments
Post a Comment