Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Dynamic Web API problem #1828


User avatar
0
asseco created

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)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you share your AppService method and jtable definition ?

  • User Avatar
    0
    asseco created

    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&lt;AnnouncementListDto&gt;(totalCount, announcements.ToList().MapTo&lt;List&lt;AnnouncementListDto&gt;>());
        }
    

    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 = $('&lt;span&gt;&lt;/span&gt;');
                                        
                    if (_permissions.edit) {
                        $('&lt;button class=&quot;btn btn-default btn-xs&quot; title=&quot;&#39; + app.localize(&#39;Edit&#39;) + &#39;&quot;&gt;&lt;i class=&quot;fa fa-edit&quot;&gt;&lt;/i&gt;&lt;/button&gt;')
                            .appendTo($span)
                            .click(function () {
                                _EditAnnouncementModal.open({ id: data.record.id });
                            });
                    }
    
    
                    if (_permissions.delete) {
                        $('&lt;button class=&quot;btn btn-default btn-xs&quot; title=&quot;&#39; + app.localize(&#39;Delete&#39;) + &#39;&quot;&gt;&lt;i class=&quot;fa fa-trash-o&quot;&gt;&lt;/i&gt;&lt;/button&gt;')
                            .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');
                }
            }
        }
    
    });
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    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({})
    
  • User Avatar
    0
    asseco created

    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

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks for sharing your solution.