I am trying to use jtable and in listaction method calling appservice, but i am getting this error : "There is an action GetAnnouncements defined for api controller app/announcement but with a different HTTP Verb. Request verb is GET. It should be Post".
How can i resolve this issue?
5 Answer(s)
-
0
Hi,
Can you share your AppService method and jtable definition ?
-
0
here appservice: public PagedResultOutput<AnnouncementListDto> GetAllAnnouncements(GetAnnouncementInput input) { var totalCount = 0; var announcements = _announcementRepository .GetAll().Include(x => x.User).Include(x => x.AnnouncementDescription);
totalCount = announcements.Count(); announcements = announcements.OrderBy(x => x.CreationTime).PageBy(input); return new PagedResultOutput<AnnouncementListDto>(totalCount, announcements.ToList().MapTo<List<AnnouncementListDto>>()); }
here jtable definition: _$announcementsTable.jtable({
title: app.localize('Announcement'), paging: true, sorting: true, multiSorting: true, actions: { listAction: { method: _announcementService.getAllAnnouncements } }, fields: { id: { key: true, list: false }, actions: { title: app.localize('Actions'), width: '12%', sorting: false, list: _permissions.edit || _permissions.delete, display: function (data) { var $span = $('<span></span>'); if (_permissions.edit) { $('<button class="btn btn-default btn-xs" title="' + app.localize('Edit') + '"><i class="fa fa-edit"></i></button>') .appendTo($span) .click(function () { _EditAnnouncementModal.open({ id: data.record.id }); }); } if (_permissions.delete) { $('<button class="btn btn-default btn-xs" title="' + app.localize('Delete') + '"><i class="fa fa-trash-o"></i></button>') .appendTo($span) .click(function () { _announcementService.deleteAnnouncement(data.record); }); } return $span; } }, announcementDescription: { title: app.localize('AnnouncementDescription'), width: '8%', display: function (data) { var descriptions = ''; for (var j = 0; j < data.record.announcementDescription.length; j++) { if (abp.localization.isCurrentCulture(data.record.announcementDescription[j].LanguageName)) { descriptions = data.record.announcementDescription[j]; } }; return descriptions; } }, publishDate: { title: app.localize('PublishDate'), width: '8%', display: function (data) { return moment(data.record.publishDate).format('L'); } }, expirationDate: { title: app.localize('ExpirationDate'), width: '8%', display: function (data) { return moment(data.record.expirationDate).format('L'); } } } });
-
0
Hi,
I'm not sure if this is related to jtable or not.
Do you use ASP.NET Core version of abp ? Do you only get this error for this specific method ?
And can you try to call this method in developer console like this.
abp.services.app.announcementService.getAllAnnouncements({})
-
0
I have fixed it. I install postman (chrome extension) and found problem: I was using entity object in Dto, and rewrite to use it with additional dto to mapp this entity.
thanks for responce
-
0
Thanks for sharing your solution.