Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

API: Exclude fields for Webhook creation

(0) ShareShare
ReportReport
Posted on by 12

Good morning dear community,

my situation is the following:

My BC 22 SaaS is exposing a custom made API page for items. I will not include all fields, but just as an example:

------------------------------

number:

description:

netWeight:

syncingStatus:

------------------------------

The external target system (let´s call it WMS) subscribed successfully to the API and is notified via Webhook in case there is a relevant action for this page (create, change, delete).

All working fine until here.

Now the WMS should send back the "syncingStatus" to the API page (Success or Error), so that we can see in BC, if the item was successfully synced to WMS.

That also works fine.

But, changing the "syncingStatus" triggers a new change webhook towards WMS, which results in a kind of loop.

My questions:

1. Is it possible to exclude single fields from the API page, to not trigger a webhook in case of a change?

2. Does the design of the API page make sense in general to use it as "read" and "write" at the same time? Is it better to create a new API page, to receive the sync Status there?

Thanks a lot for your help

Best regards

Björn 

  • Bjoern Waninger Profile Picture
    Bjoern Waninger 12 on at
    RE: API: Exclude fields for Webhook creation

    Hi DAnny3211,

    thanks a lot for your reply. It confirms my assumption.

    Regarding the "exclude" from API page, that was perhaps not explained correctly from me:

    The syncing Status is only changed via the API. If I would remove the field from the API page, it would no longer be possible to set it from WMS.

    But the more I think about it, the more i like the idea of having separated pages for read and write.

    Best regards

    Björn

  • Verified answer
    DAnny3211 Profile Picture
    DAnny3211 9,272 Super User 2024 Season 1 on at
    RE: API: Exclude fields for Webhook creation

    hi

    yes, it is possible to exclude single fields from the API page in Business Central. You can do this by modifying the API page and removing the syncingStatus field from it. This way, any changes made to the syncingStatus field will not trigger the webhook towards WMS. Alternatively, you could create a separate API page that only exposes the syncingStatus field and use it specifically for syncing the status between Business Central and WMS.

    The design of the API page can work for both "read" and "write" operations, but it may be better to separate the "write" operations into a separate API page. This can help avoid the loop issue you are experiencing, as well as improve the clarity and organization of your API pages. By separating the "write" operations into a different API page, you can better control which fields trigger a webhook and ensure that only the relevant data is being synced between the two systems.

    In summary, it is possible to exclude single fields from the API page to avoid triggering a webhook, and it may be beneficial to separate "read" and "write" operations into different API pages to improve organization and prevent loops.

    DAniele

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans