JavaScript Integration for Microsoft Dynamics NAV

I have developed a JavaScript Addin for Microsoft Dynamics Nav 2013. The Addin functions properly when used on the same machine as Navision. However, when I replace "localhost" with the machine's name, the Addin stops working. Below is the script I am using:

$(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 advice on how to resolve this issue would be greatly appreciated.

Thank you.

Answer №1

It seems like you might be using the incorrect URL.

To find the right links in Microsoft Dynamics NAV 2013, follow these steps:

  1. Open the RoleTailored client.
  2. In the Search box, type Web Services, and click on the related link.

You will see a list of all the available web services for your Microsoft Dynamics NAV setup. For further information, refer to the official documentation on MSDN.


Important Note:

It's possible that the URLs listed may be incorrect due to certain configuration settings you may not have access to.

I encountered this issue when attempting to connect to the web services at our company's Microsoft Dynamics NAV installation. The way I resolved it was by replacing the <Server> section of my

http://<Server>:<ODataWebServicePort>/<ServerInstance>/OData/
URLs with the <Server> part of the URL I use to log in to my web client. The section from <ODataWebServicePort> onward (
:<ODataWebServicePort>/<ServerInstance>/OData/...
) should be accurate.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Implement input validation in React by enhancing the functionality of HTML input tags

Below is the input provided: const REGEX_EMAIL_VALIDATION = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}&bsol ...

Struggling to decide on the perfect CSS selector for my puppeteer script

I am trying to use puppeteer page.type with a CSS selector. <div class="preloader"> <div class="cssload-speeding-wheel"></div> </div> <section id="wrapper" class="login-register"> <div class="login-box"> <d ...

Trouble with AJAX BitMovin: unable to process GET request

I've been struggling to find a solution to my problem as I cannot pinpoint what exactly to search for. My current issue involves using AJAX for a PHP Get request, causing it to submit and navigate away from the page. The BitMovin library appears to b ...

What is the preferred method for $_POST to handle multiple parameters when they are passed as a single string?

Trying to implement an Ajax call using JQuery, PHP, and MySQL. The task involves sending two variables: $speaker_id and $article_id. The jQuery construction looks like this: $('.ajax-call').click(function() { var speakerID = <?=$speaker ...

Check if the element with the ID "products" exists on the page using JQuery. If it does, then execute a certain action

Is there a way to create a conditional statement that executes if the element with the ID "products" is present in the HTML code? Thanks in advance for your help! Pseudo code using JavaScript (JQuery) if ( $('#products').length ) { // do s ...

The W3C validator verifies the cached iteration of the website

Click here The most recent error is on Line 420, Column 42: Found a stray start tag script. <script src="/skin/sayan_health/js/nc.js"></script> However, I managed to fix this error by placing the script tag inside the body tag. When I inspec ...

JWPlayer has a built-in delay of 5 seconds before executing an action following the completion of a

I am looking to customize the JWPlayer so that it pauses for 5 seconds before playing the next video. Additionally, I want to display a loading animation at the center of the video similar to what is seen on YouTube. Here is the code snippet I am currently ...

Is it possible to populate a div using jQuery Datatable?

Seeking help with jQuery datatable as a newbie. How can I populate divs instead of tables with the data from an ajax call? The structure should resemble a table: <div id="wrap"> <div class="drow"> <div class="dco ...

If the item already exists within the array, I aim to replace the existing object with the new one

I am faced with a situation where I have an array of objects, and when a user selects an option, it adds a new object to the array. My goal is to write a code that can check if this new object's key already exists in one of the objects within the arra ...

Unexpectedly, the kaminari pagination ajax request directs to an incorrect controller

Let's kick things off with the conversations/index.html.haml file to generate a message #new_message_conversation .panel.panel-info .panel-heading %h4 Send a Bark! .panel-footer(style="p ...

Click to move directly to a specific section

This question may be common, but despite my research efforts, I have been unable to find a solution. I want to issue a disclaimer that I am new to javascript and jQuery. Here is an overview of what I am trying to achieve: I want two images that, when cli ...

Navigating to a new URL using window.location.href will seamlessly embed the new page within

I am new to JavaScript and I am facing an issue with my AJAX function. The function is supposed to navigate to a new URL, but instead of loading the new page separately as if the user had typed the URL, it gets inserted inside the same div where the button ...

The subsequent invocation of Primefaces command button action fails to trigger

I am currently experiencing a peculiar issue with my Spring integration in JSF: When I click the command button, the action method in the managed bean is successfully executed (I have omitted it in the example below). The Ajax update functions flawlessly ...

Need to remove bold formatting? Try this compact WYSIWYG editor!

Hello Stack Overflow community, I discovered a method called str.bold() that wraps text in <b></b> tags, which is perfect for a small WYSIWYG editor (I understand there are many open source solutions available, but I wanted to learn by creatin ...

Unsuccessful response from an AJAX callback function

Issue: I am able to successfully pass a value to the ajax method and execute a Select SQL query (results visible in Network tab), but I never receive any results back (I expect an alert saying "Success"). What could be causing this issue? HTML: function ...

What is the best method to securely install a private Git repository using Yarn, utilizing access tokens without the need to hardcode them

My initial thought was to utilize .npmrc for v1 or .yarnrc.yml for v2/3/4, but in all scenarios, Yarn does not even attempt to authenticate with Github. nodeLinker: node-modules npmScopes: packagescope: npmAlwaysAuth: true npmAuthToken: my_perso ...

Exploring file serving in Node.js with passport authentications

I am currently utilizing Passport with the Google strategy for authentication. Here is my folder structure: views home.html enter.html (this contains just one Google+ button) app.js routes auth.js (handles Google login) I want the client to be direc ...

Is it necessary to implement a restful API for all database interactions in my Node.js application?

Currently, I am in the process of developing a simple blogging platform utilizing mongoose, node, express, Jade, and bootstrap. As I tackle the task of loading post content, I find myself contemplating whether to conduct database operations directly within ...

Retrieve all elements from an array that have the highest frequency of occurrence

Consider an array like [1,4,3,1,6,5,1,4,4]. The element with the highest frequency in this array is 3. The goal is to select all elements from the array that have a frequency of 3, so in this case we would select [1,4]. To achieve this, one possible meth ...

Is it possible to retrieve JSON data from the server without having to reload the page?

My approach to minimize server requests involves sending a JSON file to the client and working with that data instead. However, a challenge I'm facing is preventing the page from refreshing when receiving the JSON file. I want the data to be received ...