Hi Guys, Love your work again but I am not getting my dynamic web api services resolved in the angular controllers in my project. I have created a app from the templates with angular using module zero.
The task test app from the sample works and I am able to retrieve a response using postman
<a class="postlink" href="http://localhost:6247/api/services/tasksystem/task/getTasks">http://localhost:6247/api/services/task ... k/getTasks</a>
With a json body of
{ "AssignedPersonId":null, "State":null } My interface is
public async Task<GetFlightsOutput> GetFlightsAsync(GetFlightsInput input)
And so my web api should be available at <a class="postlink" href="http://localhost:6634/api/services/app/getFlightsAsync">http://localhost:6634/api/services/app/getFlightsAsync</a>
And I also created an interface on the app service with public GetFlightsOutput GetTest1()
but that is not being found either. the error is { "message": "No HTTP resource was found that matches the request URI 'http://localhost:6634/api/services/app/getTest1'." } i.e (using the camel casing)
I thought I should add an extension to DynamicApiControllerBuilder to see the list of methods just to be sure.
Is this something to do with module zero?
Best Regards, Alistair
5 Answer(s)
-
0
Hi,
<a class="postlink" href="http://localhost:6634/api/services/app/getFlightsAsync">http://localhost:6634/api/services/app/getFlightsAsync</a> is wrong. It should be like <a class="postlink" href="http://localhost:6634/api/services/app/flights/getFlightsAsync">http://localhost:6634/api/services/app/ ... ightsAsync</a> assuming that your app service interface is IFlightsAppService. So, you missed service name (it's 'task' here: localhost:6247/api/services/tasksystem/task/getTasks).
-
0
Sorry for the delay on this.
When I try a GET on <a class="postlink" href="http://localhost:6634/api/services/app/flight/getTest1">http://localhost:6634/api/services/app/flight/getTest1</a>
I get No HTTP resource was found that matches the request URI 'http://localhost:6634/api/services/app/flight/getTest1'
And the same for my PUT 'http://localhost:6634/api/services/app/flight/GetFlightsAsync'." "message": "No HTTP resource was found that matches the request URI
And the dynamic controller in the WebAPI module is built like this DynamicApiControllerBuilder .ForAll<IApplicationService>(typeof(DailyFlightsApplicationModule).Assembly, "app") .Build(); Best Regards, Alistair
-
0
Sorry I still don't see why <a class="postlink" href="http://localhost:6634/api/services/app/getFlightsAsync">http://localhost:6634/api/services/app/getFlightsAsync</a>
Doesn't work if I use
DynamicApiControllerBuilder .ForAll<IApplicationService>(typeof(DailyFlightsApplicationModule).Assembly, "app") .Build(); with public interface IFlightsAppService : IApplicationService { Task<GetFlightsOutput> GetFlightsAsync(GetFlightsInput input); Task UpdateFlightAsync(UpdateFlightInput input); Task CreateFlightAsync(CreateFlightInput input);
GetFlightsOutput GetTest1(); }
-
0
Hi,
I think your url will be "http://localhost:6634/api/services/app/flights/getTest1".
With this url (<a class="postlink" href="http://localhost:6634/api/services/app/getFlightsAsync">http://localhost:6634/api/services/app/getFlightsAsync</a>), abp cannot know which app service's "getFlightsAsync" metho to call. Because of that, you need to include flights in it like this.
<a class="postlink" href="http://localhost:6634/api/services/app/flights/getFlightsAsync">http://localhost:6634/api/services/app/ ... ightsAsync</a>
-
0
Sorry I had no problems when I was using Durandal before for my apps. But with Angular I also have this problem that the services can not be injected into the view models.i.e In the code below the abp.services.app.flight is not found. I get this error. Error: [ng:areq] <a class="postlink" href="http://errors.angularjs.org/1.5.6/ng/areq?p0=df.views.flight.list&p1=not%20a%20function%2C%20got%20undefined">http://errors.angularjs.org/1.5.6/ng/ar ... 0undefined</a>
(function () {
var controllerId = 'app.views.flight.list'; angular.module('app').controller(controllerId, [ '$scope', 'abp.services.app.flight', 'abp.services.app.gate', function ($scope, flightService, gateService) { var vm = this; vm.localize = abp.localization.getSource('DailyFlights'); vm.flights = []; vm.gates = []; vm.refreshGates = function () { abp.ui.setBusy( null, flightService.getGatesAsync().success(function(data) { vm.gates = data.gates; }) ); }; vm.refreshGates(); $scope.data = { selectedGate: null, availableGates: vm.gates }; $scope.selectedGateId = 0; $scope.$watch('selectedGate', function(value) { vm.refreshFlights(); }); vm.refreshFlights = function () { abp.ui.setBusy( //Set whole page busy until getFlights complete null, flightService.getFlightsAsync({ //Call application service method directly from javascript AssignedGateId: $scope.selectedGateId > 0 ? $scope.selectedGateId : null, FlightState: null }).success(function(data) { vm.flights = data.flights; }) ); }; vm.changeFlight = function(flight) { taskService.updateFlightAsync({ flightId: flight.id, AssignedGateId: selectedGateId, ArrivalTime: newArrivalTime, DepartureTime: newDepartureTime }).success(function() { task.state = newState; abp.notify.info(vm.localize('FlightUpdatedMessage')); }); }; vm.getFlightCountText = function() { return abp.utils.formatString(vm.localize('XFlights'), vm.flights.length); }; } ]);
})();
Please can you help me!
Best Regards, Alistair