web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

Perform action after API request

(0) ShareShare
ReportReport
Posted on by 5

Hello, 

Is it possible to call functions after API request?

My case: 

I prepared API page for Business Central and now I need to call function after the call is send. I tired to use triggers: OnClosePage, OnQueryClosePage but those two are not working. Is there any other possibility to call function after API request in BC?

I have the same question (0)
  • Inge M. Bruvik Profile Picture
    1,057 Moderator on at
    RE: Perform action after API request

    You can define actions in your API. There are a lots of blogs around this.

    Maybe this will be at help:

    www.kauffmann.nl/.../

  • DevPl320 Profile Picture
    5 on at
    RE: Perform action after API request

    Thanks for reply.

    I know how to call service enabled action from api, but what I was looking for is different scenario.

    There is POST Api call and i want to perform action right after this call, without having to call another procedure using other call.

  • Inge M. Bruvik Profile Picture
    1,057 Moderator on at
    RE: Perform action after API request

    All your table triggers and integration events should run. So if you insert something through your API the OnInsert trigger on the table should run or any event triggers connected to that.

  • DevPl320 Profile Picture
    5 on at
    RE: Perform action after API request

    Thanks. I have one more case. There is API Page- 'Doc Header' and this page contains part with other API -'Doc Lines'. What I want to achieve is to call post function right after inserting last line. So order is like:

    1.Insert Header

    2.Insert Lines

    3.Call Post Action.

    Is it possible to call posting right after POST request or I have to prepare ServiceEnabled function, like You mentioned before, which will perform posting action?

  • Inge M. Bruvik Profile Picture
    1,057 Moderator on at
    RE: Perform action after API request

    It is possible but i would not do it that way.

    What i would do is to create a time trigger job in the job queue that every x minutes looks for new records in doc header and then post them. This is because than a failure in your posting will not affect the whole flow of your API.

    So separate the insert transaction through the API from the posting process. Allowing potential errors to be handle in what my opinion is a better way.

  • DevPl320 Profile Picture
    5 on at
    RE: Perform action after API request

    Thanks for your time, job solution looks like the best option.

  • DomRot Profile Picture
    15 on at
    RE: Perform action after API request

    Hi, I search your post because I have same problem. After some search, I have seen that the event that fire after post request, is the OnBeforeCompanyClose.

    Subscribing this event in my cu, I can perform bc post documents.

  • Inge M. Bruvik Profile Picture
    1,057 Moderator on at
    RE: Perform action after API request

    I would not recommend you to use that trigger for posting.

    You should look at some other event or some other way to do your posting.

    What is your buisness scenario ?

  • DomRot Profile Picture
    15 on at
    RE: Perform action after API request

    Hi Inge, thanks for your suggestion. I've tested this posting some inventory adjustment and worked fine.

    My api will receipt some other kind of docs like purchase receipts and sales invoice that I will try to posting in the next days.

    Why you do not recommend this trigger?

    Thanks again.

  • Inge M. Bruvik Profile Picture
    1,057 Moderator on at
    RE: Perform action after API request

    If you want to perform a posting as part of an API call you should use the bound actions in the API.

    You can look here for some examples.

    docs.microsoft.com/.../devenv-creating-and-interacting-with-odatav4-bound-action

    robertostefanettinavblog.com/.../

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sumit Singh Profile Picture

Sumit Singh 2,179

#2
OussamaSabbouh Profile Picture

OussamaSabbouh 1,999

#3
YUN ZHU Profile Picture

YUN ZHU 1,892 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans