cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver II
Resolver II

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

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.

10 REPLIES 10
Highlighted
Super User II
Super User II

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

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
Highlighted
Resolver II
Resolver II

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

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

Highlighted
Community Support
Community Support

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

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Resolver II
Resolver II

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

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.

Highlighted
Community Support
Community Support

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

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-clie...

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Resolver II
Resolver II

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

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.

Highlighted
Community Support
Community Support

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

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-request...

 

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, 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Resolver II
Resolver II

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

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 !!"); }
});
}

 

Highlighted
Community Support
Community Support

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

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (7,445)