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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Identification of source of OData call

(1) ShareShare
ReportReport
Posted on by 439

Hello all.
I hope you all are doing well.
Is there a way by x++ code to identify whether a call to the data entity exposed Odata API from “open in excel” functionality or from a regular API call by an outside application?

Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    240,349 Most Valuable Professional on at

    I don't believe there is.

    What's the business problem that you're trying to solve by using different logic for identical API requests, just sent by different API clients?

  • Subra Profile Picture
    2,002 Super User 2026 Season 2 on at

    Hi @MS-29011540-0 

    I don't think we have any option to identify the source of API call. Are you looking for any specific API's?

     

  • MS-29011540-0 Profile Picture
    439 on at

    @Martin Dráb 
    There a requirement to stop requests to a specific API but at the same time they want to take the advantage of the Odata.
    The API contains critical information in their openion don't want to expose to any other client.
    There justification is that open in excel will need a user login but any other client will need client ID/ Client Secret

  • Suggested answer
    SajeedMullaji Profile Picture
    380 on at

    @MS-29011540-0 
    No, there is no officially supported way in X++ to differentiate between an OData call from Open in Excel versus an external API call.

    Both routes hit the same /data/ OData endpoint using the Microsoft Dynamics Office Add-in and standard OAuth/Entra ID authentication. X++ session introspection classes like xSession or SysHttpHeaders do not expose a distinct flag or user-agent string that safely isolates the Excel Add-in from a Postman or external C# application using the same credentials.

    Two practical workarounds if you need source tracking:

    1) Expose a Custom Service endpoint using [SysODataActionAttribute] for your external integration — design the contract to include an explicit tracking parameter your external app passes. The Open in Excel path will never hit this endpoint.

    2) Use a separate dedicated data entity mapped exclusively for the external integration versus the one exposed for Open in Excel — this gives you entity-level differentiation in your logs.

    Hope this helps.

  • Martin Dráb Profile Picture
    240,349 Most Valuable Professional on at

    You're saying that the requirement is to block access to a specific API, but your further description suggests that it's actually about a particular authentication mechanism. Please elaborate what exactly they want to achieve.

     

    Authentication and authorization is something that happens before the access to a data entity is granted, therefore it's not what you should address in X++ code inside the entity.

     

    If they want the entity to be used for integration but not by normal users, they can handle it in F&O by granting appropriate permissions.

  • Martin Dráb Profile Picture
    240,349 Most Valuable Professional on at

    @SajeedMullaji Let me correct your first suggestion. A custom service isn't created with SysODataAction attribute - that's an OData action. By the way, the obvious problem is that you couldn't then use normal capabilities of OData document manipulation and you'd have to redesign the integration.

     

    Also, you don't explain in your other suggestion how you'd map [the data entity] exclusively for the external integration. This is actually MS-29011540-0's question. My answer is that you'd have to configure permissions accordingly (e.g. giving permissions just to the accounts for integration), but you can do that with a single entity too, can't you? So it seems to me that this suggestion doesn't really address the question.

     

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 Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
SajeedMullaji Profile Picture

SajeedMullaji 366

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 289 Super User 2026 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 260 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans