简体   繁体   中英

Calling an external API from Microsoft Dynamics Nav

I am researching how to integrate Microsoft Dynamics NAV with my existing REST API (built on Django REST Framework). What I would like to do is trigger API calls from NAV to CRUD objects via the REST API.

Reading the web services docs for NAV, it seems clear that NAV can expose a web service for other software to consume from. But can NAV consume 3rd party APIs? In the web services examples documentation , it says:

Solutions that need to execute business logic or read data from Microsoft Dynamics NAV are candidates for Web service implementation. These can also be solutions that write data to Microsoft Dynamics NAV and validate the data using existing business logic .

Also, it gives the following example of how to use web services:

Execute any kind of business logic that is more easily developed and managed in Microsoft Dynamics NAV.

However, I don't see any examples of data writing. It doesn't seem that in the exposure of web service pages or codeunits , there's a way to make calls to 3rd party APIs and execute business logic with the data that comes back within NAV. Is this actually possible?

Unfortunately not, no.

You do however have access to the full .NET framework from within the 'Development Client' of Dynamics NAV - When defining your variables select the Type of DotNet

It's far from perfect, so for larger tasks I'll create AddIns or completely external libraries (depending on version).

For something smaller like this I personally find it easiest to write it in C# as a small (console) app and the 'translate' it back into Dynamics NAV.

If you are looking for way to invoke a web service then why do you need Nav web services? Nav web services is a way to call Nav.

These can also be solutions that write data to Microsoft Dynamics NAV and validate the data using existing business logic.

This means if you invoke published Nav web service then you can pass data to your call and the data will be validated and saved to Nav. So this is about how to push data to Nav, not pull from external system.

If you want to invoke a web service from Nav consider this options:

  1. Write external wraper library (as mentioned by @SeeSharp or as described ). Then use it in C/AL as DotNet or Automation types of variables.
  2. Use existing libraries like 'Microsoft XML, v6.0'.XMLHTTP60 right in C/AL to make http calls to your web service.
  3. Do it Navision style .
  4. Last damn option is to write console application that will consume your web service and call it from Nav using shell . This is not an option, I know .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM