Calling an external webhook from a codeunit?

davidrudder
Member Posts: 2
I want to call an external webhook whenever certain tables are updated. I have a codeunit which does this, and mostly works. The code looks like:
A variable named "remote" which is of type DotNet, subtype System.Net.HttpHttpClient
function webhook
remote := remote.HttpClient();
remote.GetAsync('http://www.somecompany.com/webhook?param=foo&other=bar').Wait;
remote.Dispose();
This is then called in the OnModify trigger on a number of tables. Item, Stockkeeping Unit, Customer, etc.
The problem is when the webhook is down. The call hangs then gives an error. This keeps people from editing records when the webhook is down.
Is there any way to catch the error or tell the HttpClient to ignore problems?
Thank you!
Dave
A variable named "remote" which is of type DotNet, subtype System.Net.HttpHttpClient
function webhook
remote := remote.HttpClient();
remote.GetAsync('http://www.somecompany.com/webhook?param=foo&other=bar').Wait;
remote.Dispose();
This is then called in the OnModify trigger on a number of tables. Item, Stockkeeping Unit, Customer, etc.
The problem is when the webhook is down. The call hangs then gives an error. This keeps people from editing records when the webhook is down.
Is there any way to catch the error or tell the HttpClient to ignore problems?
Thank you!
Dave
0
Comments
-
I would suggest that you split the editing and the updating process in two parts by using the Integration Record.
You can have all the editing logged in the Integration Record and then use NAS to update the web using the Integration Record.________________________________
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com0 -
Or another way is to use the Job Queue and create a Job Queue Entry for every Edit with the required parameters for this codeunit to call the web site.________________________________
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com0 -
Hello,
something like integration record and asynch processing in separate process is one way.
If you accept the web hook not to be triggered for 100% then I believe that you may trigger the operation asynchronously and ignore the result (basically without Wait).
Regards, Igor0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions