I am posting JSON as :
{"contractId":[1,3,5,7,9],"projectId":9 }
I have configured custom action as:
var deleteContracts = builder.EntityType<Contract>().Collection.Action("DeleteItems").Returns<HttpResponseMessage>(); deleteContracts.CollectionParameter<long>("C_Id"); deleteContracts.Parameter<long>("P_Id");
I have written my Action as :
[HttpPost] public IHttpActionResult DeleteItems (ODataActionParameters param) { //DO something return null; }
and i am getting this error data:
"error": {"code": "","message": "The request entity's media type 'application/x-www-form-urlencoded' is not supported for this resource.","innererror": {"message": "No MediaTypeFormatter is available to read an object of type 'ODataActionParameters' from content with media type 'application/x-www-form-urlencoded'.","type": "System.Net.Http.UnsupportedMediaTypeException", "stacktrace": " at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken) at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)" } }
Would please someone help me to understand what am i doing wrong?
Request Header is as:
POST /ContractsWebServices/ContractsWebService/odata-contracts/Contracts/Default.DeleteItems HTTP/1.1 HOST: localhost:65314 content-type: application/json content-length: 50 { "contractId":[1,3,5,7,9], "projectId":9 }
any help would be appreciated?