web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Background Process

(0) ShareShare
ReportReport
Posted on by 212

Hi

  On Click of Button how to call a REST API from NAV 2009 R2 by passing data in nested Json format.

Thanks

I have the same question (0)
  • Suggested answer
    JAngle Profile Picture
    133 on at

    You have web services available in that version. Publish some pages and you can work with them like odata. Publish a codeunit and you can pass over xml

  • Jsingh Profile Picture
    212 on at

    Hi

      Can u pls provide any link . I want to use Rest Api with Json . Is it possible

    Thanks

  • Suggested answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    PROCEDURE ConvertToJson@1240060005(VAR TempBlob@1240060000 : Record 99008535);
        VAR
          XmlDocument@1240060003 : DotNet "'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlDocument";
          JsonConvert@1240060002 : DotNet "'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.Newtonsoft.Json.JsonConvert";
          JsonText@1240060001 : Text;
          JsonFormatting@1240060004 : DotNet "'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.Newtonsoft.Json.Formatting";
          InStr@1240060005 : InStream;
          OutStr@1240060006 : OutStream;
        BEGIN
          TempBlob.Blob.CREATEINSTREAM(InStr);
          XmlDocument := XmlDocument.XmlDocument;
          XmlDocument.Load(InStr);
          JsonText := JsonConvert.SerializeXmlNode(XmlDocument.DocumentElement,JsonFormatting.Indented,TRUE);
          TempBlob.INIT;
          TempBlob.Blob.CREATEOUTSTREAM(OutStr,TEXTENCODING::UTF8);
          OutStr.WRITETEXT(JsonText);
          //MESSAGE(JsonText);
        END;
    

    In that version, you don't have all the codeunits which handles Json, you need to copy that code from new versions, I did this for NAV 2013 R2.  You can create Xml and then covert it to Json, something like above

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,151

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,443 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,092 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans