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 :
Microsoft Dynamics CRM (Archived)

Build Web API Endpoint URL

(0) ShareShare
ReportReport
Posted on by

I am working On WebAPI for retrieving data. WebAPI endpoint is something we build like this 

var orgUrl = Xrm.Page.context.getClientUrl();
var apiVersion = "/api/data/v8.2/";
var query = "?$select=ObjectTypeCode&$filter=LogicalName eq " + "'" + entityname + "'";
var queryString = orgUrl + apiVersion + "EntityDefinitions" + query;

But I have the main problem is that we have 2013,2015,2016 and also V9.0. I cannot hard code the Versions like v8.2 or v7.0 or v6.1 . If i have to hard code, i need to maintain 3 different copies just for small change in endpoint.

I can get CRM version from Soap Request and I can define the endpoint But Soap Request is deprecating. I don't want to use that. 

Is there a better way to know what is the WebApi endpoint? or a  better way that working in any CRM.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Build Web API Endpoint URL

    Hi Janaki,

    You can retrieve api version using Xrm.Page.context.getVersion(),it will give you  a version like "8.2.1.176". So you need to split   first 3 char to get the version.

    And then concatenate with organisations url.

    Hope this helps.

  • Community Member Profile Picture
    on at
    RE: Build Web API Endpoint URL

    Hi Goutam,

    Xrm.Page.context.getVersion() is not their in 2015,2013. So it does not work.

    Thanks,

    Janaki

  • gdas Profile Picture
    50,091 Moderator on at
    RE: Build Web API Endpoint URL

    Hi Janaki ,

    In that case I would suggest try to create one configuration entity with key value pair , where you can add record like with key (UATAPPI , DEVAPI) and value ((ex .xxxxx.api.crm.dynamics.com/.../v9.0, xxxxx.api.crm.dynamics.com/.../v8.2).

    You can create an utility file and call SDK.REST with organization service call to retrieve the configuration stored API  URL.

    This is alternate options instead of hard code in the code.

    Hope this helps.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans