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

Receive Data via Http and Respond using Webservice

(0) ShareShare
ReportReport
Posted on by 5

Hey NAV Users/Devs,

I got a little stuck with webservices. We never had to use one before so I am pretty new to this topic.

So, a third party software calls my NAV Webservice and sends JSON or XML data via HttpPost. The data contains an e-mail address, which i have to look for in our Customer Table and respond with let's say the customer name and address, also in JSON or XML.

I know this will involve Codeunit 1297 or 1237 but as simple as that, there are so many confusing articles and posts out there, so i got lost in all the information.

I would be really glad if one of you guys could help me out here with a simple explanation or even some examples.

Thanks and best regards from Austria,
Daniel

I have the same question (0)
  • Suggested answer
    THE Italian Profile Picture
    on at

    You might find some sample for this old version all over internet and mibuso. Here is one example

    navfreak.com/.../

    The best solution, in this case, would be to upgrade to Dynamics 365 Business Central and use HttpClient datatype that does all of your are in need natively and in a more robust way.

    docs.microsoft.com/.../httpclient-data-type

  • _daru Profile Picture
    5 on at

    Hi Duilio,

    thanks a lot for your response. As your latter solution is not an option for the moment, I ended up writing an Asp.net core Wep Api, handling all incoming Requests and responding with the desired Json String. The Asp.net Core solution is way more flexible imo.

    If someone is interested in the source code, feel free to message me.

    Cheers,

    Daniel

  • THE Italian Profile Picture
    on at

    That is great to hear :-) 

    You could always any time blog it or put your cod on GitHub to empower the whole community. 

    Well done.

  • Muhammad Arif Maseed Profile Picture
    782 on at

    Hello just change the json body

    uri := FakturaBoksSetup."Base URL" + 'api/Kreditorer/';
    RequestHeaders := Client.DefaultRequestHeaders();
    RequestContent.WriteFrom('[{"Cvr": "' + VatNo + '", "Leverandoernavn": "' + vendor.Name + '","Leverandoernummer": "' + Vendor."No." + '", "Regnr_kontonr": "' + vendor."Preferred Bank Account Code" + '","Regnskab": "' + FakturaBoksSetup."Company Name" + '"}]');
    RequestContent.GetHeaders(contentHeaders);
    contentHeaders.Clear();
    vHttpRequestMessage.Method := ('POST');
    RequestHeaders.Add('Authorization', CreateBasicAuthHeader());
    contentHeaders.Add('API_KEY', FakturaBoksSetup."Access Key");
    contentHeaders.Add('Content-Type', 'application/json');
    vHttpRequestMessage.SetRequestUri(uri);
    vHttpRequestMessage.Content := RequestContent;
    Client.Send(vHttpRequestMessage, ResponseMessage);
    ResponseMessage.Content().ReadAs(ResponseText);

  • Bodhi Profile Picture
    558 on at

    1, create a codeunit, write a funtion in the codeunit

      jason file as a parameter variable

      use a .net addin to parse the Jason file

      use the field name to get data from Jason file and assign to fieldref

      the value will be in table

     we can return a jason as return value

    2, post this codeunit in the Webservices in NAV

    3, the third party software calls the Webservices( like postman)

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 2,606

#2
YUN ZHU Profile Picture

YUN ZHU 931 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans