# Connect Dynamics NAV

A Dynamics NAV that runs on your own servers, behind a firewall, can be connected to Peaky through a [Peaky Connector](/doc/peaky-connector-on-premise-systems-tSV5gikiVC). The connector reaches NAV's OData web services from inside your network and lets Peaky read from them, and nothing else. This also covers Business Central on-premises, which serves the same OData web services. A NAV reachable from the internet needs no connector — see [Accounting & ERP](/doc/accounting-fSYP3czo81#dynamics-nav).


---

## Before You Start

* A connector installed and **Connected** — see [Peaky Connector (On-premise Systems)](/doc/peaky-connector-on-premise-systems-tSV5gikiVC), and [Run on Docker](/doc/run-on-docker-o5CZCzqkk4), [Run on Linux](/doc/run-on-linux-h1rOBYadEK), [Run on Windows](/doc/run-on-windows-Q0AucWclz0) or [Run on Kubernetes](/doc/run-on-kubernetes-scvf7JLIud). The connector's machine must be able to reach your NAV server's OData port (7048 unless you changed it).
* The **OData web services** for the chart of accounts and G/L entries published in NAV, and a NAV user with a **Web Service Access Key**, as for any NAV — see [Accounting & ERP](/doc/accounting-fSYP3czo81#dynamics-nav).


---

## Add NAV to the Connector

Add a target for NAV to the connector's configuration file, `/etc/peaky-connector/connector.toml`. Its `url` is the address the connector's machine reaches NAV at, **with the server instance**: the same address you would enter in Peaky without a connector.

```toml
[[target]]
name = "nav"
url = "https://nav.mycompany.internal:7048/DynamicsNAV140"
profile = "nav-readonly"
```

If NAV uses a certificate from your own certificate authority, or a self-signed one, add `ca_file` with the path to that certificate — see [The configuration file](/doc/peaky-connector-on-premise-systems-tSV5gikiVC#the-configuration-file). Restart the connector to load the new target, and check that it reaches NAV:

* **Docker:** `docker restart peaky-connector`, then `docker exec peaky-connector peaky-connector check`. See [Run on Docker](/doc/run-on-docker-o5CZCzqkk4#change-the-configuration).
* **Linux service:** `sudo systemctl restart peaky-connector`, then `sudo systemd-run --wait --pipe --quiet --collect -p EnvironmentFile=-/etc/peaky-connector/connector.env /usr/local/bin/peaky-connector check`. See [Run on Linux](/doc/run-on-linux-h1rOBYadEK#change-the-configuration).
* **Windows service:** `Restart-Service PeakyConnector`, then `& 'C:\Program Files\Peaky Connector\peaky-connector.exe' check`, in PowerShell as administrator. See [Run on Windows](/doc/run-on-windows-Q0AucWclz0#change-the-configuration).
* **Kubernetes:** see [Run on Kubernetes](/doc/run-on-kubernetes-scvf7JLIud#change-the-configuration), then `kubectl -n peaky-connector exec peaky-connector-0 -- peaky-connector check`.

Within a minute, the **Connectors** tab lists **nav** under the connector's **Targets**.

### The nav-readonly profile

With `profile = "nav-readonly"`, the connector lets through only requests that **read** NAV's OData web services, V4 and V3. Everything else is refused at the connector, whatever rights the NAV user has: creating, changing or deleting records, running actions, batches of requests, and NAV's SOAP web services. Peaky's NAV sync only ever reads, so it needs nothing more.

The profile decides what kind of request is allowed, not which records can be read: that is still up to the NAV user's permissions and which web services you published.


---

## Connect NAV Through It


1. Find **Dynamics NAV** under the **Accounting & ERP** tab on the **Integrations** page and click **Connect**.
2. Under **Where does your Dynamics NAV run?**, choose **On your own network, through a Peaky Connector**.
3. Choose the **Connector**. The **Target** is filled in from what the connector reported — `nav` unless you named it differently. Only targets with the **nav-readonly** profile are offered, and the connector has to have connected once since you added it.
4. Choose the **OData version**, and fill in the **Company**, **Username** and **Web Service Access Key** as for any NAV. Click **Connect**.

Peaky checks the connection through the connector before saving it, and queues the first sync. From here, NAV works as it does without a connector. Your access key is stored in Peaky like any other integration's credentials, not on the connector.


---

## Troubleshooting

| Connecting NAV says | Likely cause | What to do |
|---------------------|--------------|------------|
| *The connector is not connected to Peaky* | The connector is stopped, or its machine or network is down | Start it again (see [Run on Docker](/doc/run-on-docker-o5CZCzqkk4#troubleshooting), [Run on Linux](/doc/run-on-linux-h1rOBYadEK#troubleshooting), [Run on Windows](/doc/run-on-windows-Q0AucWclz0#troubleshooting) or [Run on Kubernetes](/doc/run-on-kubernetes-scvf7JLIud#troubleshooting)), wait until it shows **Connected**, then try again |
| *The connector refused the request* | The configuration has no target of that name, or it lacks `profile = "nav-readonly"` | Check the target's `name` and `profile`, restart the connector, and use the same name as **Target** |
| *The connector has not reported a target of this name with the nav-readonly profile* | The target is missing, has another profile, or was added after the connector last connected | Add `profile = "nav-readonly"` to the target, restart the connector, and wait until it shows **Connected** |
| *Could not reach NAV at this address* | The connector is running but cannot reach NAV | Run `peaky-connector check` in the connector (see [Run on Docker](/doc/run-on-docker-o5CZCzqkk4#check-it), [Run on Linux](/doc/run-on-linux-h1rOBYadEK#check-it), [Run on Windows](/doc/run-on-windows-Q0AucWclz0#check-it) or [Run on Kubernetes](/doc/run-on-kubernetes-scvf7JLIud#check-it)) and check the target's `url` and port from the connector's machine |
| *NAV answered, but has no OData service of this version there* | The server instance in the target's `url` is wrong, or NAV serves the other OData version | Check the instance name (such as `DynamicsNAV140` or `BC130`) and the **OData version** |
| *NAV refused these details* | The username or access key is wrong | Check the **Username** and **Web Service Access Key** on the NAV user card |
| *NAV has no company of this name* | The **Company** does not match a NAV company exactly | Use one of the names the message lists |

For problems with the connector itself, see [Troubleshooting](/doc/peaky-connector-on-premise-systems-tSV5gikiVC#troubleshooting) on the connector's page.