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

Announcements

No record found.

News and Announcements icon
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,647 Super User 2026 Season 1 on at
    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,946 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,177 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 555 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans