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

Getting data from a Dynamics Nav web service

(1) ShareShare
ReportReport
Posted on by 69
Hi,
Is there any way to connect to Dynamics NAV 2018 Odata V4 web service with Business Central Saas?
I am trying to get the data from a web service, this is the code I use:
var
    Client: HttpClient;
    Request: HttpRequestMessage;
    Response: HttpResponseMessage;
    Content: HttpContent;
    JsonResponse: Text;
    JsonObject: JsonObject;
    RecordJson: JsonObject;
    ServiceUrl: Text;
    Username: Text;
    Password: Text;
    companyinfo: Record "Company Information";
begin
    companyinfo.FindSet();
    ServiceUrl := 'http://192.168.1.1:7049/DynamicsTest/ODataV4/Company(' + companyinfo.companyserviceweb + ')/customers';
    Username := 'SERVER\SYSTEMTEST';
    Password := '123456';
    Client.DefaultRequestHeaders.Clear();
    Client.DefaultRequestHeaders.Add('Authorization', 'Basic' + Base64Encode(Username + ':' + Password));
    Request.SetRequestUri(ServiceUrl);
    Request.Method := 'GET';
    if Client.Send(Request, Response) then begin
        Content := Response.Content();
        Content.ReadAs(JsonResponse);
        JsonObject.ReadFrom(JsonResponse);
        Message(JsonResponse);
    end else begin
        Error('Error: ' + Format(Response.HttpStatusCode));
    end;
end;
 
If I connect from the browser it asks for the credentials and I add them, it allows me to access the web service, but I can't get the information from the web service.

     
  • gdrenteria Profile Picture
    15,338 Most Valuable Professional on at
    Getting data from a Dynamics Nav web service
    Hi
    I agree with what our colleague mentioned.
    Here some useful information. 
    BR
    GR
  • Suggested answer
    YUN ZHU Profile Picture
    78,733 Super User 2025 Season 1 on at
    Getting data from a Dynamics Nav web service
    This is a local IP address, http://192.168.1.1.
    BC cannot access the local PC, including local folders, etc.
    If you make it public on the public Internet, BC should be able to access it. I think this is the problem.
     
    Hopefully other experts can give you better advice.
     
    Thanks.
    ZHU

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,884 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,760 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans