Consuming data from NAV webservice using JSON

JSON (JavaScript Object Notation) is a document with structured data used on a growing number of platforms and looks like the preferred way of handling data between iOS devices and web services.

Recently, and inspired by a NAV development training I have been looking for a way to consume data from Microsoft Dynamics NAV by the iOS platform. I found out that it is quite simple to expose data as JSON from NAV2013. Because I like to build stuff for iOS I was particular-airy interested in the possibilities.

It takes a few simple steps to download a JSON document from Navision using a webbrowser:

  1. Create a web service based on a page (my example show some seminar data from the training I did)
  2. Publish the new webservice

webservice

We need the OData URL, copy the complete URL and paste it in the address bar of your browser, then paste the following string:

?$format=json

directly behind the URL. Keep in mind that this part of the string should be lowercase. Press Enter in the address bar if you are ready. Your browser might ask you to give your credentials.

You will be presented with a file download, save it anywhere you like and open the file with a tool that can read JSON or use this service on the web.

The JSON content will look like this, in my case data from Seminars is disclosed:

json

Navision presents us with 2 objects: the metadata, after the ‘#’ we see the name of the web service the data is coming from. And the values, 3 records have been written in the file, each with 24 fields. The JSON format should be simple enough to parse in iOS, put in a dictionary and present the data to the user in a view on the device:-)

I will investigate this further and I am thinking of developing a wrapper (acting as a middleware web service between NAV and iOS client devices) that has sufficient rights to communicate with the Navision webservice and can return or receive data to/from the iOS platform without the need for Windows authentication but using pre-defined security tokens instead. If I succeed I will dedicate a couple of blogposts to it, to explain the techniques I used.

Note: instead on “json” you could also use “atom” to get an AtomPub document.

See MSDN posts:
How to: Use OData to Return/Obtain a JSON Document
Using OData Web Services to Modify Data

 

 
Comments
 
Comments

No comments yet.