Skip to main content

Notifications

Community site session details

Community site session details

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

Trying to send invoice via an API call... not authorized

(1) ShareShare
ReportReport
Posted on by 14
Hi
 
I'm trying to automate sending invoices via the API by posting to the following URL:
 
https://api.businesscentral.dynamics.com/v1.0/{tenantId}/api/v2.0/companies({companyId})/salesInvoices({salesInvoiceId})/Microsoft.NAV.Send
 
This executes successfully and returns "204 No Content", however no email is produced.
 
When reviewing the "Job Queue Log Entries" I can see an error relating to the API call:
 
 
The error message says: 
 
You are not authorized to access this resource: https://graph.microsoft.com/.default. Contact your system administrator.
 
I think the problem is that the App Registration does not have the correct permissions to send the email via the shared mailbox configured.  I have granted several Microsoft.Graph permissions including Application.ReadWrite.All and Mail.Send and still have not had any success, which makes me think there could be a configuration in BC I need to do.
 
If anyone else has encountered this and come up with a solution please let me know?  Thank you
  • Suggested answer
    Alan Shurey Profile Picture
    14 on at
    Trying to send invoice via an API call... not authorized
    Thank you for the suggestions, however I found the app registration permissions were not the issue.
     
    The call to the bound action (Microsoft.NAV.Send) was working correctly, however the email account bound to the sales invoice cannot handle the Application Registration as the user and the app permissions do not appear to be passed through to allow access to the mailbox.  Instead of using Exchange I managed to configure an SMTP email account to go out via Sendgrid (which allows me to set a basic username and password).
     
    The problem for me is that Exchange is locked down to MFA users so I cannot use basic authentication.  Not sure if this is the best solution, however its worked for me so I'm happy.
  • Gerardo Rentería García Profile Picture
    19,937 Most Valuable Professional on at
    Trying to send invoice via an API call... not authorized

    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
    YUN ZHU Profile Picture
    84,557 Super User 2025 Season 1 on at
    Trying to send invoice via an API call... not authorized
    This looks like a permissions issue with OAuth authentication.
    Please check your App Registration permissions.
     
     
    Thanks
    ZHU
  • Suggested answer
    Anthony Blake Profile Picture
    2,507 Super User 2025 Season 1 on at
    Trying to send invoice via an API call... not authorized
    Hi Alan,
     
    Mail.Send & User.Read should be enough API permissions to send email from a shared mailbox, I set this scenario up this week, albeit from D365 Finance.
     
    User.Read should be assigned by default, but make sure it hasn't been removed.
     
    Also check that the API permissions are not awaiting administrator approval in Azure.
     
    Anthony

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 1,452

#2
YUN ZHU Profile Picture

YUN ZHU 1,313 Super User 2025 Season 1

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 1,083 Most Valuable Professional

Featured topics

Product updates

Dynamics 365 release plans