• Une évaluation gratuite
  • Navigator
  • Academy
  • Partner Portal
  • Devenez partenaire du QBS Group
  • France
    • Global
    • Belgique - Français
    • België - Nederlands
    • Danmark
    • Deutschland
    • España
    • Italia
    • Nederland
    • Norge
    • Österreich
    • Polska
    • Schweiz
    • Sverige
    • United Kingdom
  • Global Global Global en
  • Belgique - Français Belgique - Français Belgique - Français fr-be
  • België - Nederlands België - Nederlands België - Nederlands be
  • Danmark Danmark Danmark da
  • Deutschland Deutschland Deutschland de
  • España España España es
  • France France France fr
  • Italia Italia Italia it
  • Nederland Nederland Nederland nl
  • Norge Norge Norge no
  • Österreich Österreich Österreich at
  • Polska Polska Polska pl
  • Schweiz Schweiz Schweiz ch
  • Sverige Sverige Sverige sv
  • United Kingdom United Kingdom United Kingdom en-uk
QBS group
Menu
  • Informations
    • Blogs
    • Actus
    • Close
  • Événements
  • Solutions logicielles
  • Services
    • QBS Academy
    • Services Azure by QBS
    • Close
  • Programmes
    • Ready to Start – Programme Microsoft Dynamics 365 Business Central
    • Fournisseur indirect Microsoft CSP
    • Programme ISV
    • Nos partenaires
    • Close
  • Qui sommes-nous
    • Qui sommes-nous
    • Vision, Mission and Strategy
    • Timeline
    • Contact
    • Close
Blog écrit par:
Temps pour lire:n.v.t.
Partagez ceci:
  • Partager sur Facebook
  • Partager sur Twitter
  • Partager sur Google+
  • Partager sur Linkedin
  • Partager par Mail
22 mars 2021

How to use the Dynamics 365 Business Central API with C# in Service-to-Service scenarios

Vous êtes ici : Accueil » How to use the Dynamics 365 Business Central API with C# in Service-to-Service...

Business Central

Dynamics 365

Tech

A question that was raised more frequently than others lately is, how to use the Business Central API from C# in Service-to-Service scenarios?

Within the Business Central community, C# is the most frequently used language to code Azure Functions and Windows Services using DotNET core.

There are a few choices to make when deciding how to design your code and we’ll discuss the most important ones being security and structure of your classes.

Security

When you connect to Business Central using the API you have two choices. OAuth with tokens or Basic with a Web Service Access Key.

Using OAuth is the preferred solution which is promoted by Microsoft. The problem is that OAuth is only supported when the software calling into Business Central has the ability to provide a user interface.

This user interface is required to show a window to login and return the access token.

Business Central currently does not support OAuth in service-to-service scenarios except for the API that is handling the service tier itself.

That leaves you with the choice of going back to Basic authentication with a Web Service Access Key or to use Azure as the middle man.

Most examples that you can find online of authentication use the latter option and therefor this blog is about the other option that is hard to find information on.

Simplicity is the core value of Business Central and even though customers using Business Central have an Office 365 tenant, not everyone has their Azure tenant configured.

Using Azure as the middle man for security may be the easy way out for a developer, it requires each user of your solution to set this up in their Azure tenant.

The advice is to use Basic Authentication for Service-to-Service connections until Microsoft is finished with a final solution for OAuth in these scenarios.

Classes

There are two options when you design your solution to structure your classes. You can have them generated based on the metadata of the API endpoint or you can design your own classes.

Both options have pros and cons and the most important reason why the example repository creates its own classes is again simplicity and to explain clearly how the API works rather than working through a pile of generated code that will leave 95% unused.

In real life implementations, many developers will choose to generate the classes based on the endpoint, especially if the API has strong versioning like the one provided by Microsoft.

A strong exception would be if you only need a few API methods implemented or if the API is a custom API for a project and subject to change.

If changes to the API happen on a frequent basis, which is not recommended but happens often in real-life scenarios, you can be more flexible in your error handling if you define your classes yourself.

Rest Client

To send data back and forth your code needs a Rest Client and, in the example, we use the one from RestSharp. This is a very popular NuGet package. Another frequently used Rest Client is the Simple Client (Simple.OData.Client) which is also available as NuGet package.

Json Handling

Json is not native to C#. It was created for JavaScript and in order to use it in C# you can use either NewtonSoft or the new System.Text.Json from Microsoft. Both are created by the same person who works for Microsoft now.

You will most likely find out that both libraries have scenarios where they work and fail.

NewtonSoft Linq supports the use of JArray and JObject in a similar way as AL has the native JsonArray and JsonObject although you will find the NuGet libraries much more flexible and powerful.

Value

Each result that you get from Business Central has a wrapper with a tag called [Value]. In almost all cases you won’t need this in your code. The function ConvertToDataSet converts the result of an API call into a Json Array without the [Value] wrapper.

The API Endpoint

When Business Central is hosted by Microsoft the API endpoint has up to 6 variables that determine things like the Sandbox you are using (if any), the Tenant ID (obsoleted by OAuth) and the details about the API version, and group.

Learning more

To work effectively with the Business Central API it is important to have in-depth knowledge of Json and Rest. QBS Group offers a dedicated workshop to gain this knowledge.

Resources

Link to Github: https://github.com/qbsgroup/QBS.API.Example
https://www.kauffmann.nl/2021/01/07/deprecation-of-basic-auth-for-saas-has-been-postponed-to-2022/
https://www.kauffmann.nl/2020/09/14/service-to-service-authentication-for-automation-apis-in-business-central/
https://www.youtube.com/watch?v=dp_mzqzNvPA&t=1553s

Plus d’articles

Ce qui pourrait également vous intéresser

  • Hébergement Azure pour Dynamics NAV/Business Central ?

    Qu’est-ce que l’hébergement Azure pour Dynamics NAV/Business Central et […]

  • Do you really need the Business Central Universal Code Initiative? Are you shocked? Let’s hope not…

    What’s the Business Central Universal Code Initiative? For a […]

  • Dynamics 365 Update Webcast – 9 December 2021

    Microsoft Dynamics 365 update 9 décembre 2021 Ce webcast […]

  • Directions EMEA in Milan and we as QBS Group will be there!

    It was a tough year without meeting each other […]

  • The Dynamics 365 Migration Journey – Infographic
  • En tant qu’entreprise informatique, votre organisation est-elle prête à vendre Microsoft Business Solutions ?
  • Partenaire, développez un business model réussi avec Dynamics 365 Business Central

    En tant que revendeur de logiciels, qu’est-ce que cela […]

  • Solution ERP Microsoft Dynamics 365 Business Central pour les PME

    Que vaut Microsoft Dynamics 365 Business Central en tant […]

  • Dynamics 365 Update Webcast 1 July 2021

    This series of webcasts is intended to share the […]

  • Cosmos versus Azure SQL and how to integrate with Dynamics 365 Business Central #MSDYN365BC

    One of the highest-scoring FAQs from partners and customers […]

  • Dynamics 365 Update Webcast 27 May 2021

    This series of webcasts is intended to share the […]

  • Get Insights from Microsoft about the directions of Business Central in the SMB Channel

    Michael Hartman, CEO of QBS Group, interviewed Mike Morton, […]

  • ERP Migration – the Friendly Hill That One Day May Become a Hostile Mountain

    Cloud computing is probably the most profound IT-innovation of […]

  • Comment obtenir la compétence Microsoft Cloud Business Applications pour PME ?

    Microsoft a communiqué sur les prérequis indispensables à l’obtention […]

  • Why is Application Insights so important with Dynamics 365 Business Central?

    I can understand why some people would still refrain […]

  • Ready to Start – Programme Microsoft Dynamics 365 Business Central
  • Dynamics 365 Update Webcast 10 December 2020

    This series of webcasts is intended to share the […]

  • Dynamics 365 CRM Update Webcast 6 November 2020

    Get the latest insights from Microsoft Dynamics 365 CRM […]

  • Why is Azure SQL so important for Dynamics 365 Business Central?

    Let us start with a common question: “When a […]

  • Dynamics 365 CRM Update Webcast 16 October 2020

    Get the latest insights from Microsoft Dynamics 365 CRM […]

  • Dynamics 365 Update Webcast 15 October 2020

    This series of webcasts is intended to share the […]

  • What is the MB-800 Microsoft Dynamics 365 Business Central Exam and why does it matter?

    Microsoft has launched a brand-new certification exam for Dynamics […]

  • Dynamics 365 CRM Update Webcast 4 September 2020

    Get the latest insights from Microsoft Dynamics 365 CRM […]

  • Why use Azure BLOB Storage with Business Central?

    What is Azure BLOB Storage and why is this […]

  • QBS Summer School 2020

    Even with the new normal, summer remains the perfect […]

  • Dynamics 365 Update Webcast 25 June 2020

    This series of webcasts is intended to share the […]

  • Dynamics 365 CRM Update Webcast 24 June 2020

    Get the latest insights from Microsoft Dynamics 365 CRM […]

  • From NAV via Business Central on-premises to Cloud

    In this time of digital transformation, it is recommended […]

  • Best practices of migrating your customer to Business Central SAAS

    “Migrating Dynamics NAV customers to Dynamics 365 Business Central […]

  • Dynamics 365 and Power Platform licensing model explained

    Get the latest insights from Microsoft Dynamics 365 CRM […]

  • Dynamics 365 CRM Update Webcast 11 May 2020

    Get the latest insights from Microsoft Dynamics 365 CRM […]

  • Dynamics 365 Update Webcast 7 May 2020

    This series of webcasts is intended to share the […]

  • Dynamics 365 Update Webcast 6 February 2020

    This series of webcasts is intended to share the […]

  • Update on Dynamics 365 Business Central 18 November 2019

    This series of webinars is intended to share the […]

  • Dynamics 365 Business Central 2019 release Wave 2

    As of October 1, 2019, Microsoft has launched Dynamics […]

  • Directions EMEA 2019 is less than 1 month away! Are you ready?

    Come meet us – as always we will have […]

  • QBS Marketplace
  • Update on Dynamics 365 Business Central 27 August 2019

    This series of webinars is intended to share the […]

  • Microsoft raised the bar for competencies

    October 24, 2019 update. Microsoft has gone back on their […]

  • New Pricing for Dynamics 365 Customer Engagement & Unified Operations per the 1st of October 2019

    Microsoft announces new Pricing for Dynamics 365 Customer Engagement […]

  • Promo on Dynamics 365 for Sales to Office 365 customers

    Launched on May 1st, 2019 running until October 31st […]

  • Dynamics 365 Business Central April 2019 update – key findings

    April 19 2019 Dynamics 365 Business Central Release   Our […]

  • Update on Dynamics 365 Business Central 13 June 2019

    This series of webinars is intended to share the […]

  • The 7 secrets you must know to be successful with your Dynamics 365 App

    In 2019 we celebrate 30 years of the world […]

  • Update on Dynamics 365 Business Central 9 May 2019

    Watch here the Webinar update of the 9th of May 2019.

  • What does the latest Dynamics 365 Business Central Update (April ’19) mean for Europe, Middle East & Africa?

    The April 2019 Business Central Licensing Guide has recently been released, but are there differences from the previous ones? In short, yes.

  • Press release: QBS group becomes majority shareholder of 1ClickFactory

    Leusden, The Netherlands, April 2019   QBS group and […]

  • L’équipe QBS group Mid Europe rencontre 1ClickFactory

    Depuis le début de l’année, QBS group représente 1ClickFactory au Benelux. Il s’agit dès lors de la 2e région où QBS group constitue le point de contact exclusif de 1ClickFactory. Toutefois, quelle est l’action de 1ClickFactory et de quels avantages nos partenaires QBS group peuvent-ils bénéficier?

  • Update on Dynamics 365 Business Central 11 April 2019

    This series of webinars is intended to share the […]

  • Update on Dynamics 365 Business Central 14 March 2019

    Technical update and License update 1 April 2109

  • All you need to know about Microsoft Dynamics NAV coming to an end and becoming Microsoft Dynamics 365 Business Central

    (this page will continuously be updated as information arrives) […]

  • White Paper – Microsoft Dynamics 365 the perfect platform for digital transformation in the mid-market

    At QBS group we’re all about Dynamics partners – […]

  • Update on Dynamics 365 Business Central 7 February 2019

    This series of webinars is intended to share the […]

  • Ready to Start Microsoft Dynamics 365 Customer Engagement
  • Directions EMEA 2018 Business Report

    This unique report features a broad but insightful and independent business reporting on the happenings at DIRECTIONS EMEA 2018.

  • Microsoft Dynamics 365 – the perfect platform for new business ventures

    Microsoft has thousands of business partners. Is this market not the red ocean?

  • Ready to Go for Dynamics 365 Business Central
  • Ready to Start Microsoft Dynamics 365 Customer Engagement program – Reference MKB365

    MKB365 has set up a separate business model for […]

  • Highlights from eXtreme 365 EMEA 2018

    Get all the highlights of eXtreme 365 EMEA 2018 and watch this 6 minutes video.

  • What can Dynamics CRM Partners expect from eXtreme365 EMEA 2018?

    eXtreme 365 is the annual event for Microsoft Dynamics […]

  • The evolution of Dynamics 365 opens the door for new opportunities

    Being a Dynamics CRM partner today is like dancing on a volcano – far from boring!

  • “Ever change a winning team”

    “Ever change a winning team” Alex Ferguson, former football […]

  • What’s new NAV 2018

    Understanding these new possibilities is crucial for your product and / or marketing plans.

  • GDPR … and what now ?

    Starting from 25 May 2018 there is going to be a […]

  • Position NAV as stepping stone for more Dynamics 365 ‘Tenerife’ deals

    Since the introduction of the Dynamics 365 Business Edition in the US and Canada late 2016, the position of Dynamics NAV is under pressure! Competitors took the chance to position NAV as an old-fashioned solution and that’s a direct threat to your NAV business!

  • Exclusive interview with Jeff Edwards Director for ERP Channel Strategy Microsoft

    “If you’re an ERP partner not selling CRM, and not having a focus on verticals in 2018 – I don’t know what you’re doing”

  • Dynamics 365 Business Central sur Microsoft Azure
  • Services de mise à niveau
  • Dynamics 365 for Sales Acceleration Program
  • Programme éditeurs

    En tant qu’éditeur, vous axez principalement vos efforts sur […]

  • Fournisseur indirect Microsoft CSP

    En tant que revendeur Microsoft, vous envisagez de collaborer […]

  • DIRECTIONS EMEA 2017 business report is available now!

    Never before it was so important for Dynamics partners […]

  • Business Edition is off – long live Tenerife!

    Our team is just getting back from Directions in […]

  • QBS Academy
  • Nos partenaires
  • Directions EMEA 2017 Madrid

    Find here all the information you as Microsoft Reseller […]

  • Reflections on this weeks announcements from Microsoft

    One of our founders summarized this week plain and […]

  • The CSP Direct model is like an iceberg

    We noticed that the market is changing, our clients are, more and more, requesting a subscription based approach. This allows them to not have their own services nor the hassle.

  • General Data Protection Regulations (GDPR) – a Microsoft perspective

    The EU General Data Protection Regulation (GDPR) is the […]

  • Inspire 2017 – A look back at 11 big stories for Microsoft Dynamics Partners

    As a longtime WPC / Inspire-observer with a perspective […]

  • Part 4 Microsoft Dynamics Development Preview

    Microsoft released during last Christmas an Azure Virtual Machine […]

  • What Dynamics Partners can expect from Inspire 2017

    Microsoft is on the move! Ever since the start […]

  • 7 Strong arguments to sell Dynamics NAV today

    Dynamics NAV finds itself in an interesting position today! […]

  • Dynamics NAV Development: Extensions or Extinction?

    No one wants to be a dinosaur, it does […]

  • Do you know your new competitors with Dynamics 365 for Financials?

    The new kids-on-the-block with outsell you on Dynamics 365 […]

  • What is the Microsoft Cloud Solution Provider Program (Microsoft CSP)

    The Microsoft Cloud Solution Provider Program (CSP) enables partners to directly manage their entire Microsoft cloud customer lifecycle.

  • Dynamics 365 Business Edition: Opportunity or Threat

    Microsoft will be launching Dynamics 365 Business Edition in […]

  • Get yourself a niche, in order to be successful

    At QBS group we believe that our partners deserve […]

  • After Directions EMEA 2016, Microsoft Dynamics NAV partners face crucial decisions on their future

    As a longtime Microsoft-observer with a perspective geared toward […]

  • What is the Microsoft CSP Program?

    In order to be successful in a Cloud first, […]

Ce que l’on dit à propos du Groupe QBS

  • Ferry Schrijnewerkers

    Owner en Co-founder at MKB365

    Since the start of our company 4 months ago, we have already completed 12 Dynamics 365 for Sales implementations.

    Read the reference case
  • Joaquim Antón Gimeno

    GRUPO CHOICE

    "Our relationship with QBS group allows us to improve our marketing strategy."

    Read the reference case
  • Sofkia

    "Our alliance with QBS group has been very important in the development of our business strategy."

    Read the reference case
  • VS Sistemas

    "QBS group helps us build our road to success."

    Read the reference case
  • Berith Skov - C2IT Business Solutions

    “We are very satisfied with the services provided by and through QBS group."

    Read the reference case
  • Herke ICT Group- Karing Buzing

    We are once again part of a NAV community.

    Read the reference case
  • Owe Loonstra - Verito

    Manager Sales & Marketing

    The fact that we belong to a larger organisation gives our customers security.

    Read the reference case
  • Adfocom - Jeroen Kersten

    Partner Care saved us a lot of time.

    Read the reference case
  • NavAzure - Michael Francois Knudsen

    “It is important to me, that I through QBS become part of a greater network, where partners can share experience"

    Read the reference case
  • Blisss - Dirko Wijers

    Without the help from QBS group we wouldn’t have succeeded.

    Read the reference case

Programme

  • Devenir partenaire
  • Fournisseur indirect du programme Microsoft CSP
  • Programme ISV
  • Nos partenaires

Centre d’Information

  • Références
  • Blog
  • Formation
  • Événements
  • Actus
  • Newsletter

Prestations de service

  • Dynamics 365 Business Central sur Microsoft Azure
  • Services de mise à niveau
  • QBS Academy

Follow QBS group

© Copyright QBS group 2023
  • Cookie Policy
  • Privacy Policy
Get Insights from Microsoft about the directions of Business Central in the... Dynamics 365 Update Webcast 27 May 2021
We are now Companial!

This is our old website, we’re now Companial.

The content on this page might be outdated.

Enjoy all the new information on our new website.

 

Go to Companial

Contactez-nous, merci de remplir ce formulaire

Rejoignez le QBS Group veuillez remplir le formulaire

Rejoignez le QBS Group veuillez remplir le formulaire

Veuillez remplir le formulaire

Veuillez remplir le formulaire

Veuillez remplir le formulaire


If you are not seeing the form, please check your ad-blocker settings.

Sign up QBS Group Membership

Send me an email.
Download Center

Register for this event
QBS
  • France
    • Global
    • Belgique - Français
    • België - Nederlands
    • Danmark
    • Deutschland
    • España
    • Italia
    • Nederland
    • Norge
    • Österreich
    • Polska
    • Schweiz
    • Sverige
    • United Kingdom
  • Informations
    • Blogs
    • Actus
    • Back
  • Événements
  • Solutions logicielles
  • Services
    • QBS Academy
    • Services Azure by QBS
    • Back
  • Programmes
    • Ready to Start – Programme Microsoft Dynamics 365 Business Central
    • Fournisseur indirect Microsoft CSP
    • Programme ISV
    • Nos partenaires
    • Back
  • Qui sommes-nous
    • Qui sommes-nous
    • Vision, Mission and Strategy
    • Timeline
    • Contact
    • Back

Nous utilisons des cookies pour vous offrir la meilleure expérience possible. En cliquant sur le bouton "Accepter", vous acceptez les cookies et consentez à la politique de confidentialité.

Faire défiler vers le haut