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

REST API Business Centra;: Unable to Insert Data into table due UserId

(1) ShareShare
ReportReport
Posted on by 79
Hello, I am seeking assistance on the following:

I am working on a Business Central Extension. I have enabled REST API / Web Services via OAUTH 2.0 with the main goal of creating an retrieving data between BC and an app.

I am struggling to insert data into a specific table due to a validation check against the currently logged in user (UserId). Here's the specific error:




Here's the trigger excerpt (The last error is where the above is coming from):



The error: Error('UserID' + ' ' + '[' + UserId + ']' + ' has not been assigned to any employee. Please consult the HR officer for assistance'), is grabbing the User Name for the Microsoft Entra Application I created and enabled to allow for API calls to BC.



The Trigger is grabbing the User Name from the above User Information Sub section, and since that user information is not stored in the User table in Business Central, and it hasn't gone through some set ups, it will immediately fail the OnInsert trigger.

My question is, how can I change the User Information that is obtained in the API to something that I have in the User table in BC?

Or how can I add the above information to the User table in BC, so that it wont fail the check for the OnInsert?
 
I have the same question (0)
  • Suggested answer
    Yi Yong Profile Picture
    2,349 Super User 2025 Season 2 on at
    REST API Business Centra;: Unable to Insert Data into table due UserId
    Hello,
     
    I think something is not adding up here.
     
    The 'User ID' will always be 'SND BC API' because this user will be the one calling the API service.
    You are filtering HREmp to 'User ID', which doesn't add up because 'SNC BC API' should not be an employee or found in the HREmp table.
     
    Why not create a field on the APIPage and when you are posting to the API, you need to add the actual User ID to the body?
     

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,725 Super User 2025 Season 2

#2
Sumit Singh Profile Picture

Sumit Singh 2,610

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,221

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans