Options

How to call a RESTful web service that respond in JSON

eclipseseclipses Member Posts: 8
edited 2015-03-01 in NAV Three Tier
Hi all,

I watched very interesting videos about how to consume a REST web service using NAV 2013 and R2 version but all offer an example in Visual Studio.

I'd like to call the web service directly in C/AL and I don't have problem if I receive an XML response but in my case I'd like to know what is the best approch to work with a Web Service RESTful with messages in JSON.

Let me know your opinion or suggest me materials

Thank you

Eclipses

Comments

  • Options
    booneboone Member Posts: 23
    I don't have a great solution. I was looking into the same thing except I planned on using Visual Studio. Do you mind sharing the video that you watched, it might be able to help me... Thanks!
  • Options
    PureHeartPureHeart Member Posts: 190
    boone wrote:
    I don't have a great solution. I was looking into the same thing except I planned on using Visual Studio. Do you mind sharing the video that you watched, it might be able to help me... Thanks!
    ...and help me too!
    Why don't you try my compare tool?
    http://www.mibuso.com/dlinfo.asp?FileID=1123
  • Options
    Torben_Wind_Meyhoff[MSFT]Torben_Wind_Meyhoff[MSFT] Member, Microsoft Employee Posts: 22
    Use one of the free parsers out there and use .NET Interop from C/AL:
    http://james.newtonking.com/json

    Example that you can rewrite in C/AL:
    string json = @{
    'CPU': 'Intel',
    'PSU': '500W',
    'Drives': [
    'DVD read/writer'
    /*(broken)*/,
    '500 gigabyte hard drive',
    '200 gigabype hard drive'
    ]
    }";

    JsonTextReader reader = new JsonTextReader(new StringReader(json));
    while (reader.Read())
    {
    if (reader.Value != null)
    Console.WriteLine("Token: {0}, Value: {1}", reader.TokenType, reader.Value);
    else
    Console.WriteLine("Token: {0}", reader.TokenType);
    }

    // Token: StartObject
    // Token: PropertyName, Value: CPU
    // Token: String, Value: Intel
    // Token: PropertyName, Value: PSU
    // Token: String, Value: 500W
    // Token: PropertyName, Value: Drives
    // Token: StartArray
    // Token: String, Value: DVD read/writer
    // Token: Comment, Value: (broken)
    // Token: String, Value: 500 gigabyte hard drive
    // Token: String, Value: 200 gigabype hard drive
    // Token: EndArray
    // Token: EndObject

    BR
    Torben
    “This posting is provided "AS IS" with no warranties, and confers no rights.”
  • Options
    mbjmbj Member Posts: 63
    I have used the attached C/AL implementation for Web API integration. Remember to set the right ContentType for Json <application/json; charset=UTF-8> or XML <application/xml; charset=UTF-8>.

  • Options
    rthswrthsw Member Posts: 73
    Hi,
    just for the case someone is interested:
    for connecting a Navision with Shopware i wrote my own REST/JSON Wrapper direct in Navision without any additional software.

    Natural there is a external component, but only Microsoft components you find on every Windows-computer since 2003/Xp, so you don't need to setup any DLL's, programms or whatever on the using client computers.

    Currently the page is only in German because Shopware is very (only?) popular in Germany, but the examples are easy to read (just ignore the german text).

    https://sites.google.com/site/renethoen ... e-mit-josn

    If you want to drive a Shopware system out of Navision you might also be interested in a complete PIM Solution direct inside of Navision.
    Also in German but with a lot of explaining Pictures:

    https://sites.google.com/site/renethoene/navision/pim

    Hope i can help someone with this. Both Solutions are also to sell. Documentation will be more in the future.
Sign In or Register to comment.