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

Announcements

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,736 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,497 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,778 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,507

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans