2

I am using the SharePoint REST API to construct the endpoint URI as mentioned here

Working with folders and files with REST

I have a Microsoft SharePoint location which has a folder and the folder contains multiple files. I used the following:

https://xyz.sharepoint.com/teams/Data/_api/web/GetFolderByServerRelativeUrl('/teams/Data/Shared Documents/TestFolder/2020-12-14')/files 

The above returns the following XML response

<?xml version="1.0" encoding="utf-8"?> <feed xml:base="https://xyz.sharepoint.com/teams/Data/_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> 79b042e3-8a9a-4336-ac66-48a6d9e1202c </id> <title /> <updated> 2020-12-14T14:50:12Z </updated> <entry> <id> https://xyz.sharepoint.com/teams/Data/_api/Web/GetFileByServerRelativePath(decodedurl='/teams/Data/Shared Documents/TestFolder/2020-12-14/modified-bill-400394.xml') </id> <category term="SP.File" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> <link rel="edit" href="Web/GetFileByServerRelativePath(decodedurl='/teams/Data/Shared%20Documents/TestFolder/2020-12-14/modified-bill-400394.xml')" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Author" type="application/atom+xml;type=entry" title="Author" href="Web/GetFileByServerRelativePath(decodedurl='/teams/Data/Shared%20Documents/TestFolder/2020-12-14/modified-bill-400394.xml')/Author" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CheckedOutByUser" type="application/atom+xml;type=entry" title="CheckedOutByUser" href="Web/GetFileByServerRelativePath(decodedurl='/teams/Data/Shared%20Documents/TestFolder/2020-12-14/modified-bill-400394.xml')/CheckedOutByUser" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/EffectiveInformationRightsManagementSettings" type="application/atom+xml;type=entry" title="EffectiveInformationRightsManagementSettings" href="Web/GetFileByServerRelativePath(decodedurl='/teams/Data/Shared%20Documents/TestFolder/2020-12-14/modified-bill-400394.xml')/EffectiveInformationRightsManagementSettings" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/InformationRightsManagementSettings" type="application/atom+xml;type=entry" title="InformationRightsManagementSettings" href="Web/GetFileByServerRelativePath(decodedurl='/teams/Data/Shared%20Documents/TestFolder/2020-12-14/modified-bill-400394.xml')/InformationRightsManagementSettings" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ListItemAllFields" type="application/atom+xml;type=entry" title="ListItemAllFields" href="Web/GetFileByServerRelativePath(decodedurl='/teams/Data/Shared%20Documents/TestFolder/2020-12-14/modified-bill-400394.xml')/ListItemAllFields" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/LockedByUser" type="application/atom+xml;type=entry" title="LockedByUser" href="Web/GetFileByServerRelativePath(decodedurl='/teams/Data/Shared%20Documents/TestFolder/2020-12-14/modified-bill-400394.xml')/LockedByUser" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" type="application/atom+xml;type=entry" title="ModifiedBy" href="Web/GetFileByServerRelativePath(decodedurl='/teams/Data/Shared%20Documents/TestFolder/2020-12-14/modified-bill-400394.xml')/ModifiedBy" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Properties" type="application/atom+xml;type=entry" title="Properties" href="Web/GetFileByServerRelativePath(decodedurl='/teams/Data/Shared%20Documents/TestFolder/2020-12-14/modified-bill-400394.xml')/Properties" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/VersionEvents" type="application/atom+xml;type=feed" title="VersionEvents" href="Web/GetFileByServerRelativePath(decodedurl='/teams/Data/Shared%20Documents/TestFolder/2020-12-14/modified-bill-400394.xml')/VersionEvents" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Versions" type="application/atom+xml;type=feed" title="Versions" href="Web/GetFileByServerRelativePath(decodedurl='/teams/Data/Shared%20Documents/TestFolder/2020-12-14/modified-bill-400394.xml')/Versions" /> <title /> <updated> 2020-12-14T14:50:12Z </updated> <author> <name /> </author> <content type="application/xml"> <properties> <CheckInComment> </CheckInComment> <CheckOutType m:type="Edm.Int32"> 2 </CheckOutType> <ContentTag> {7CF22FF5-60B1-45C4-B843-00D6E1E66F8C},1,1 </ContentTag> <CustomizedPageStatus m:type="Edm.Int32"> 0 </CustomizedPageStatus> <ETag> "{7CF22FF5-60B1-45C4-B843-00D6E1E66F8C},1" </ETag> <Exists m:type="Edm.Boolean"> true </Exists> <IrmEnabled m:type="Edm.Boolean"> false </IrmEnabled> <Length m:type="Edm.Int64"> 205 </Length> <Level m:type="Edm.Byte"> 1 </Level> <LinkingUri m:null="true" /> <LinkingUrl> </LinkingUrl> <MajorVersion m:type="Edm.Int32"> 1 </MajorVersion> <MinorVersion m:type="Edm.Int32"> 0 </MinorVersion> <Name> modified-bill-400394.xml </Name> <ServerRelativeUrl> /teams/Data/Shared Documents/TestFolder/2020-12-14/modified-bill-400394.xml </ServerRelativeUrl> <TimeCreated m:type="Edm.DateTime"> 2020-12-14T13:38:37Z </TimeCreated> <TimeLastModified m:type="Edm.DateTime"> 2020-12-14T13:38:37Z </TimeLastModified> <Title> modified-bill-400394.xml </Title> <UIVersion m:type="Edm.Int32"> 512 </UIVersion> <UIVersionLabel> 1.0 </UIVersionLabel> <UniqueId m:type="Edm.Guid"> 7cf22ff5-60b1-45c4-b843-00d6e1e66f8c </UniqueId> </properties> </content> </entry> <entry> ---------- ---------- </entry> </feed> 

There is a lot of unnecessary information here for my end goal. I only want the service call to return the information for <ContentTag> </ContentTag> for all <entry> </entry>.

How can I construct the URI to return the following desired output. Is there any way to use XQuery like path expression to get to what I want?

 <feed xml:base="https://xyz.sharepoint.com/teams/Data/_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> 79b042e3-8a9a-4336-ac66-48a6d9e1202c </id> <title /> <updated> 2020-12-14T14:50:12Z </updated> <entry> <ContentTag> {7CF22FF5-60B1-45C4-B843-00D6E1E66F8C},1,1 </ContentTag> </entry> <entry> <ContentTag> {A02D8998-A06C-4581-931D-00119FBD98AC},1,1 </ContentTag> </entry> <entry> <ContentTag> {56F12492-A080-4EC6-A229-0014FD75150A},1,1 </ContentTag> </entry> </feed> 

Thank you in advance.

    1 Answer 1

    1

    Use below endpoint:

    https://xyz.sharepoint.com/teams/Data/_api/web/GetFolderByServerRelativeUrl('/teams/Data/Shared Documents/TestFolder/2020-12-14')/files?$select=ContentTag 
    1
    • 1
      thanks for the solution. It worked. I initially thought that SQL like select statement only works on sharepoint lists. I am surprised to see that it works on XML structure as well.
      – smpa01
      CommentedDec 16, 2020 at 13:55

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.