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 :
Small and medium business | Business Central, N...
Suggested answer

Multi-tenant application's API to access Dynamics 365 Business Central company.

(1) ShareShare
ReportReport
Posted on by 2
I need to get the API response for a business central company using the multi-tenant app's client ID, and secret key.
I tried the below OAuth API to get the company's response. But I got the message as a bad request.
 
using (HttpClient client1 = new HttpClient())
{
    string companiesEndpoint = https:/api.businesscentral.dynamics.com/v2.0/organizations//+environment_name+/api/v2.0/companies/;
    string Access_Token = Session[/BCAccessToken/].ToString();
    client1.DefaultRequestHeaders.Add(/Authorization/, /Bearer / + Access_Token);
    HttpResponseMessage response1 = await client1.GetAsync(companiesEndpoint);
    if (response1.IsSuccessStatusCode)
    {
        string jsonResponsevalue = await response1.Content.ReadAsStringAsync();
        var Items = JsonConvert.DeserializeObject<dynamic>(jsonResponsevalue);
        JArray signItemtoken1 = (JArray)Items[/value/];
        foreach (var response in signItemtoken1)
        {
            string ComapnyName = response[/name/] != null ? (string)response[/name/] : //;
            string CompanyID = response[/id/] != null ? (string)response[/id/] : //;                                            
            if (ComapnyName == company_name)
            {
                Session[/BCCompanyName/] = CompanyName;
                Session[/BCCompanyId/] = CompanyID;
            }
        }                                            
    }
}
 
How to call an API to get company details or items from Dynamics 365 Business Central?
I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at
    Multi-tenant application's API to access Dynamics 365 Business Central company.
    Are you facing any error?
     
  • Gerardo Rentería García Profile Picture
    24,091 Most Valuable Professional on at
    Multi-tenant application's API to access Dynamics 365 Business Central company.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,901

#2
YUN ZHU Profile Picture

YUN ZHU 2,079 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 2,041

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans