Skipping the discussion about which is better to use, OData endpoint or API endpoint....
In VS Code, when you add an OData Connected Service, you need to provide credentials if the service requires that.
This is not very clear, documentation can be found here: docs.microsoft.com/.../accessing-endpoints-with-auth
In this case, the best option is to use basic authentication.
To do this, follow these steps:
1. From the user card in BC, get the username (the part before the domain name) and the web service access key.
2. Put them together with a colon in between: <username>:<web service access key>
3. Base64 encode this string. I use https://www.base64encode.org/ for this
4. In Visual Studio, in the Configure endpoint page, specify this address: (with https before it, left out because of automatic formatting)
api.businesscentral.dynamics.com/v2.0/[tenant]/[environment]/ODataV4/$metadata
whereas [tenant] = domain name of the user and [environment] = production or sandbox or any other named environment.
5. Select "Include Custom Http Headers"
6. Add this header:
Authorization: Basic <base64 encoded string from step 3>
And click Next.
Now you should get to the next page where you can select which webservice(s) you want to use.