web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Business Central forum

Business Central Sandbox tenant API connection

(0) ShareShare
ReportReport
Posted on by

I'm struggling to get an API connection working while following the documentation here (https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-develop-connect-apps#exploring-the-apis-with-postman-and-basic-authentication)

I've setup my web authentication key for my user and I've tried using my full username with @ourdomain.com and without, the URL I've got my endpoint set to is https://api.businesscentral.dynamics.com/v1.0/ourdomain.com/api/beta

The response I get back from this call is 

{
    "error": {
        "code": "Authentication_InvalidCredentials",
        "message": "The server has rejected the client credentials."
    }
}


Can anybody offer any help in getting this working? I'd really like to try and prototype an integration with Business Central

Categories:
I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: Business Central Sandbox tenant API connection

    You’ve to call the API by using Basic authentication and passing your userid (without the domain name) and your web service access key as password.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Business Central Sandbox tenant API connection

    hi,

    1)   In addition to what Demiliani said (using Basic authentication, your Username without domain name and your Web Service Access Key as password), don't add your domain name in the endpoint link. Try to use the link generated in your Web Services page as it is without any change.

    2) check if you have the permissions set for the object you wanna call.

    ,

    I hope this helps you and answers your question.

    Please verify my answer if you find it helpful.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: Business Central Sandbox tenant API connection

    Exactly. I’ve not checked your endpoint url but you need to use the base url as show in the OData field in web service page.

  • Community Member Profile Picture
    on at
    RE: Business Central Sandbox tenant API connection

    I'm following the instructions on https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-develop-connect-apps#exploring-the-apis-with-postman-and-basic-authentication

    which say to call GET api.businesscentral.dynamics.com/.../<your tenant domain>/api/beta

    I'm accessing the Business Central sandbox tenant, not a local NAV install just so you know. I'm not aware of how to access the web services section on Business Central?

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Business Central Sandbox tenant API connection

    hi,

    Just search for the page Web Services.

    As you can see in the image bellow, there is already some web services already created. Just copy any URL of any web service and consume it from Postman (don't forget to use in Postman Basic authentication, your Username without domain name and your Web Service Access Key as password) or you can as well open it in the browser with your credentials (your Username and your Web Service Access Key).

     

    WebServices.png

    Please verify my answer if you find my answer helpful. Doing so you'll show other community members that there was found a solution and you credit my help.

  • joshbooker Profile Picture
    on at
    RE: Business Central Sandbox tenant API connection

    For the sandbox, you simply append /sandbox after your domain like:

    https://api.businesscentral.dynamics.com/v1.0/ourdomain.com/sandbox/api/beta

    As others have said,

    For basic auth: you need to first setup permissions in BC, use the Web Service Access Key from BC in Postman to call the tenant specific endpoint.  

    For AAD Auth/OAuth: you first setup an App Registration in Azure AD and use the ClientID and Secret from Azure Portal in postman to call the common endpoint (no tenant name in url).  

    To test your auth, first call

    https://api.businesscentral.dynamics.com/v1.0/ourdomain.com/api/beta

     and you should get the metadata for all entities in the response.  If not, troubleshoot your authentication.

    If your auth is good, then try the sandbox endpoint.

    To prove it's the sandbox, you can compare response from /companies endpoints.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Business Central Sandbox tenant API connection

    Hi,

    Check this:

    https://www.youtube.com/watch?v=Sm_K6ToxYGc&list=PLcakwueIHoT-wVFPKUtmxlqcG1kJ0oqq4&t=71s&index=18

    .

    Please verify my answer if you find my answer helpful. Doing so you'll show other community members that there was found a solution and you credit my help.

    ,

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Business Central Sandbox tenant API connection

    Managed to resolve this in the end. I resetup my authentication key and made sure I was using just my user name. What I think the actual problem was is that the documentation refers to the end point uri as consisting of /v1.0/ourdomain.com/api/beta HOWEVER the ourdomain.com bit isn't actually your 'domain' but the GUID for the tenant. For example...

    api.businesscentral.dynamics.com/v1.0/5a61b000-1ec5-47ea-b726-000f9c2df000/api/beta/


    Once I was calling the correct endpoint everything worked and I've managed to build a working prototype integration very quickly. Thanks for everyone's help!

  • joshbooker Profile Picture
    on at
    RE: Business Central Sandbox tenant API connection

    Glad you got it working.  

    Tenant GUID always works.  Your domain depends on whether your tenancy has verified domains in AAD.  

    For example, if you login to Dyn365 with a work account matt@yourdomain.com then yourdomain.com is a verified domain so it can be used in the url in place of GUID.  If you login instead with the default matt@yourdomain.onmicrosoft.com then yourdomain.onmicrosoft.com is what you want in the url.

    HTH,

    Josh

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans