Calling an external webhook from a codeunit?

davidrudderdavidrudder Member Posts: 2
edited 2014-03-27 in NAV Three Tier
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

Comments

  • thegunzothegunzo Member Posts: 274
    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.com
  • thegunzothegunzo Member Posts: 274
    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.com
  • ichladilichladil Member Posts: 68
    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, Igor
Sign In or Register to comment.