Get page's blocks in EPiServer Content delivery API

592 Views Asked by At

I have a page in Episerver / Optimizely, with a page that has some blocks, but I want to access the blocks through https://localhost:5000/api/episerver/v3.0/content/57 (whith episerver content delivery api), but the blocks won't follow. Is it possible to return the blocks with the page?

2

There are 2 best solutions below

0
On

This is an ODATA api, you'll need to tell it to expand the properties you want to see

To expand everything

https://localhost:5000/api/episerver/v3.0/content/57?expand=*

To expand a certain property

https://localhost:5000/api/episerver/v3.0/content/57?expand=propertyToExpand

Comma separate properties to expand if multiple

https://localhost:5000/api/episerver/v3.0/content/57?expand=propertyToExpand,otherPropertyToExpand

Optimize your query by using select (you should)

https://localhost:5000/api/episerver/v3.0/content/57?expand=propertyToExpand,otherPropertyToExpand&select=propertyToExpand,otherPropertyToExpand
1
On

Strangely enough, for me using expand does work but I can't even access a page by calling its id. I get a 404 response from the call if I try something like:

https://localhost:5000/api/episerver/v3.0/content/5&expand=*

And if I try to call a none existing id, I get a 500 response.

But if I assign a friendly url (ie: start) to my page whose id is 5, I can call it through that:

https://localhost:5000/api/episerver/v3.0/content?ContentUrl=start&expand=*