6

My question is very simple. I would like to display the recent top 10 news with the REST API in Sharepoint 2013. I'm using the following query:

http://my-server/my-news/_api/web/lists/GetByTitle('Pages')/items?$select=Id,Name,Title,Comments&$orderby=ArticleStartDate%20desc&$top=10&$filter=Title+ne+'Home'

Now I would like to select the link to the news page. But as far as I know, there is no property that I can get that would give me the URL of the page.

Anyone knows a way, via the REST query, to get the URL? Thanks!

2 Answers 2

9

Have you tried getting the column 'FileRef'?

If not can you construct the URL using the Name?

2
  • Wonderful, FileRef is working. Thank you so much! (Might want to edit your post from FieldRef to FileRef) Commented Jan 23, 2014 at 21:16
  • Here is the link for FileRef: msdn.microsoft.com/en-us/library/… Commented Jan 24, 2014 at 0:30
6

FileRef field in $select query option will return page url.

For example, the query:

https://fabrikam.sharepoint.com/_api/web/Lists/getbytitle('Pages')/items?$top=1&$select=Id,Title,FileRef

will return:

    <?xml version="1.0" encoding="utf-8"?>
<feed xml:base="https://fabrikam.sharepoint.com/_api/" 
    xmlns="http://www.w3.org/2005/Atom" 
    xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" 
    xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" 
    xmlns:georss="http://www.georss.org/georss" 
    xmlns:gml="http://www.opengis.net/gml">
    <id>07244208-09fa-4014-bd1f-785a73b8d4a1</id>
    <title />
    <updated>2014-01-23T21:14:58Z</updated>
    <entry m:etag="&quot;5&quot;">
        <id>78183075-e864-4e76-8efb-38bf6e2190f9</id>
        <category term="SP.Data.PagesItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
        <link rel="edit" href="Web/Lists(guid'a976fb47-81fa-47ae-a487-7d6d656a54ce')/Items(1)" />
        <title />
        <updated>2014-01-23T21:14:58Z</updated>
        <author>
            <name />
        </author>
        <content type="application/xml">
            <m:properties>
                <d:Id m:type="Edm.Int32">1</d:Id>
                <d:Title>Home</d:Title>
                <d:ID m:type="Edm.Int32">1</d:ID>
                <d:FileRef>/Pages/default.aspx</d:FileRef>
            </m:properties>
        </content>
    </entry>
    <link rel="next" href="https://fabrikam.sharepoint.com/_api/web/Lists/getbytitle('Pages')/items?%24skiptoken=Paged%3dTRUE%26p_SortBehavior%3d0%26p_ID%3d1&amp;%24top=1&amp;%24select=Id%2cTitle%2cFileRef" />
</feed>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.