Hi friends,
Struggling with OData V4 when calling a Function.
My Client sends to the service:
http:
The webapi service expects:
http:
I have tried so many things but I cannot figure out how this works.
How do I get client and service work together
Service is asp.net web api
Client is
"ProviderId": "Microsoft.OData.ConnectedService",
"Version": "0.4.0",
What I have tried:
In the webapiconfig I added the route
config.Routes.MapHttpRoute(
name: "ActionAPI",
routeTemplate: "api/{controller}/{action}/{id})",
defaults: new { id = RouteParameter.Optional }
);
The entity is defined in the config as
modelBuilder.EntitySet<ProjectUsedModels_Result>("ProjectUsedModels");
The controller contains:
[EnableQuery]
public IEnumerable<ProjectUsedModels_Result> Get(string modelNumber = "")
{
try
{
var result = db.ProjectUsedModels(modelNumber);
return result;
}
catch (Exception err)
{
Logging.Log.Instance.AddException(err);
return new List<ProjectUsedModels_Result>();
}
}
Client Calling Code:
public IEnumerable<ProjectUsedModels_Result> SearchProjectsThatUsedModel(string modelNumber)
{
var modelnumberParameter = new UriEntityOperationParameter("modelNumber", modelNumber);
var uri = new Uri("ProjectUsedModels", UriKind.Relative);
return Service.Execute<ProjectUsedModels_Result>(uri, "GET", false, modelnumberParameter);
}