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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to get CDS data us...
Power Apps
Unanswered

How to get CDS data using API? (As we get sharepoint list data using rest API).

(0) ShareShare
ReportReport
Posted on by 357

Currently i am using SharePoint list for showing data in my SharePoint page using REST API.
My simple question is that, do we have any API by which we can get data of CDS(Common Data Service).
Please help me if any one have any idea.

I have the same question (0)
  • Hamish Sheild Profile Picture
    3,005 Most Valuable Professional on at
    Hi,

    There is an API for CDS. Get started by taking a look at this article

    https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/overview
  • sayyed007amir Profile Picture
    357 on at

    Can you please give me an example of calling an entity.
    Because i tried but not able to get data.

  • v-xida-msft Profile Picture
    on at

    Hi @sayyed007amir ,

    Do you want to retrieve CDS data using web API within canvas app?

     

    Based on the needs that you mentioned, I think the custom connector could achieve your needs. On your side, you could consider create a custom connector based on Common Data Service Web API, then specify proper action/operation within the custom connector.

    After that, you could use the custom connector action to retrieve CDS data in your canvas app. More details about creating a custom connector in PowerApps, please check the following article or video:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/register-custom-api

    https://www.youtube.com/watch?v=dBCS1nPsDiE&t=2s

    (Note: Essentially, the custom connector action would send HTTP request to your CDS Web API to retrieve data)

     

    More details about the Common Data Service Web API, please check the following article:

    https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/overview

     

    Please take a try with above solution, check if could help in your scenario.

     

    Best regards,

  • sayyed007amir Profile Picture
    357 on at

    No, i don't want to get CDS data in Powerapps.
    I want to get CDS data in SharePoint wiki page in the form of array object using JavaScript or any programming language.

  • v-xida-msft Profile Picture
    on at

    Hi @sayyed007amir ,

    I think JavaScript code or C# code could achieve your needs. More details about calling CDS Web API using JavaScript, please check the following samples:

    https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/web-api-samples-client-side-javascript

     

    Best regards,

  • sayyed007amir Profile Picture
    357 on at

    Still i am not able to get CDS Data.
    Can you please give me an example where CDS Environment Name and Entity name visible in code.

  • v-xida-msft Profile Picture
    on at

    Hi @sayyed007amir ,

    Actually, when you use CDS Web API to fetach data from CDS Entity, the standard URL Address looks like below:

    [Organization URI]/api/data/v9.1/entityname?$select=name,revenue

    The URL you will use will be composed with these parts: Protocol + Environment Name + Region + Base URL + Web API path + Version + Resource.

    More details about the Web URL structure, please refer to the following artilce:

    https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/compose-http-requests-handle-errors#web-api-url-and-versions

     

    If you want to get the Organization URI for your specific Environment, please consider go to Power Platform Admin Center, then switch Environments tab, then find your specific Environment, click it. Then you would find the Organization URL as below:

    1.JPG

    If I want to fetch Account Entity data from my current Environment using Web API, the HTTP request URL should be as below:

    https://org4xxxxxxx.crm5.dynamics.com/api/data/v9.1/accounts

    You could also append some query options to above url:

    https://org4xxxxxxx.crm5.dynamics.com/api/data/v9.1/accounts?$select=name&$top=3

     

    More details about querying data from CDS Entity using Web API, please check the following article:

    https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/query-data-web-api

     

    Best regards, 

  • sayyed007amir Profile Picture
    357 on at

    Still not able to get data. Am i missing any thing. Refer attachment to see error screenshot.
    Code:

    function getdata() {
    var url = "https://xxxxxxx.crm6.dynamics.com/api/data/v9.1/accounts?$top=3";
    return getAjaxResponse(url).then(function (response) {
    cdsdata = response.d.results ;
    });
    }
    function getAjaxResponse(url) {
    var def = $.Deferred();
    return $.ajax({
    url: url,
    type: "GET",
    cache: false,
    headers: {
    "accept":" application/json; odata=verbose",
    "Content-Type":"application/json",
    "OData-MaxVersion":" 4.0",
    "OData-Version":" 4.0",
    "If-None-Match":" null"
    },
    success: function (response) { def.resolve(response);alert("success"); },
    error: function (err) { def.reject(err);console.log("API failed !!"); }
    });
    }

     

  • v-xida-msft Profile Picture
    on at

    Hi @sayyed007amir ,

    Currently, you could not access CDS data through Web API using AJAX directly. You need to provide authentication for your ajax request.

     

    Please check the following article for more details:

    https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/authenticate-oauth

     

    Best regards,

  • sayyed007amir Profile Picture
    357 on at

    Hi,
    Thanks for helping me but still i am not able to get data.
    I am new to this platform and even not much knowledge with ajax.
    I created application in Azure app services with Dynamics permission, and i have application id, client id and all.
    Please help me through a working ajax code, so that i can get data.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard