0

I have created an Addin using JavaScript for Microsoft Dynamics Nav 2013, it works fine when I am using it in the same machine where Navision is. Nevertheless,when I replace “localhost” for the name of the machine, it does not work. This is my script:

$(document).ready(function() {
    //This does not work
    var url = "http://myService:7057/OData/Company('Company')/CRMSPABookings?$format=json"; 

    // This works
    // var url = "http://localhost:7057/OData/Company('Company')/CRMSPABookings?$format=json"; 
    $.ajaxSetup({
        xhrFields: {
            withCredentials: true
        }
    });

    var http_request = new XMLHttpRequest();   
    http_request.open("GET", url, false);
    http_request.withCredentials = "true";

    http_request.send();
    xmlDocImage = http_request.responseText;
    var x = JSON.parse(xmlDocImage);              
});

Any suggestion?

Thank you very much.

John Slegers
  • 45,213
  • 22
  • 199
  • 169
Jose Luis
  • 1
  • 2

1 Answers1

0

Most likely, you're using the wrong URL.

Normally, here's where you should look for the correct links in Microsoft Dynamics NAV 2013 :

  1. Open the RoleTailored client.
  2. In the Search box, enter Web Services, and then choose the related link.

This should give you a list with all existing web services for your Microsoft Dynamics NAV installation. See the official docs on the MSDN for more info.


Note :

It is possible that the URLs in this list are incorrect, probably due to some obscure configuration setting you may not have access to.

This happened to me when trying to connect to the web services at the Microsoft Dynamics NAV installation we're using at the company I'm working for. What fixed it for me, is to replace the <Server> part of my http://<Server>:<ODataWebServicePort>/<ServerInstance>/OData/ links with the <Server> part of the URL I'm using to log in to my web client. Everything from <ODataWebServicePort> onward (:<ODataWebServicePort>/<ServerInstance>/OData/...) SHOULD BE correct.

Community
  • 1
  • 1
John Slegers
  • 45,213
  • 22
  • 199
  • 169