Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Companies endpoint permission issue

(1) ShareShare
ReportReport
Posted on by 23
Hello I am trying to query the /api/v2.0/companies endpoint, i get a proper response when using the CRONUK/CRONUS test accounts, when i choose my real company, i keep getting (i added the xxxx in the url to hide my environment) :
 
Client error: `GET https://api.businesscentral.dynamics.com/xxxxxxxxxxxxxxxx/api/v2.0/companies` resulted in a `401 Unauthorized` response:
{"error":{"code":"Authentication_InvalidCredentials","message":"Web service call failed because user could not be authen (truncated...)
 
I get an access token and a refresh token fine. Infact all other companies that i have tested with works fine, but not the production one where i am trying with a non admin user. Can anyone please advise where i can give selective permission so as that user can also be able to query this companies endpoint? I do also have an admin account it works with the admin account, but i wanted to grant selective permission to just a specific user to be able to choose which company id to work with, I can't seem to find this in a documentation or the UI of business central. 
 
 
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 76,516 Super User 2024 Season 2 on at
    Companies endpoint permission issue
    Because it is a 401 error, it seems to be a problem with the OAuth settings.
    It is recommended to check the App Registration settings.
     
    Thanks.
    ZHU
  • CU21011505-0 Profile Picture
    CU21011505-0 4 on at
    Companies endpoint permission issue
    Check extension permissions. If extensions are used, verify and grant the necessary permissions.
  • gdrenteria Profile Picture
    gdrenteria 13,350 Most Valuable Professional on at
    Companies endpoint permission issue

    Hi, good day
    I hope this can help you, and give you some hints.

    Using OAuth to connect Business Central APIs and Web Service in Postman | Dynamics 365 Lab

    Best Regards
    Gerardo

  • Suggested answer
    Khushbu Rajvi. Profile Picture
    Khushbu Rajvi. 7,144 on at
    Companies endpoint permission issue
    I get an access token and a refresh token fine. Infact all other companies that i have tested with works fine, but not the production one where i am trying with a non admin user. Can anyone please advise where i can give selective permission so as that user can also be able to query this companies endpoint?
     
    @PU-21010544-0  Does this mean you have tested all the companies where this works fine, and those are in the sandbox? And in production, you are encountering the issue?
  • Suggested answer
    Bilal Haider Profile Picture
    Bilal Haider 113 on at
    Companies endpoint permission issue
    Hi,
     
    It looks that your user have company specific rights. You can navigate to Users page and then if you open your user and go to User Permission set tab, you will see that the permissions assigned to you might be for specific company. If you want to assign these permissions for all companies then make the company field empty. 

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Share Your Event with the Community

Jump start your event engagement! 📢

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,961 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,717 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans