0

I'm using API call /GetFolderByServerRelativeUrl('/path/to/folder')/Files?$select=ListItemAllFields/ID,ListItemAllFields/FileRef,Properties&$expand=ListItemAllFields,Properties&$top=10&$skip=10 to retrieve data about files in folder.

While on my test env (or on SharePoint cloud) I receive files' creation/modification times, and sizes (file-lengths), on my client those fields are missing from the xml.

What's the cause for this difference? How can I fix this?

  • My client runs SharePoint 2013 Standard with SP1, patched to Jan 2018 CU.

Client's API response:

<entry>
    <id>http://domain/_api/Web/GetFileByServerRelativeUrl('/path/to/some/file.ext')</id>
    <category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="SP.File"/>
    <link href="Web/GetFileByServerRelativeUrl('/path/to/some/file.ext')" rel="edit"/>
    <link href="Web/GetFileByServerRelativeUrl('/path/to/some/file.ext')/ListItemAllFields" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ListItemAllFields" title="ListItemAllFields" type="application/atom+xml;type=entry">
        <m:inline>
            <entry m:etag="&quot;5&quot;">
                <id>Web/GetFileByServerRelativeUrl('/path/to/some/file.ext')/ListItemAllFields</id>
                <category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="SP.Data.CDODocsItem"/>
                <link href="Web/GetFileByServerRelativeUrl('/path/to/some/file.ext')/ListItemAllFields" rel="edit"/>
                <title/>
                <updated>2018-08-27T09:58:06Z</updated>
                <author>
                    <name/>
                </author>
                <content type="application/xml">
                    <m:properties>
                        <d:Id m:type="Edm.Int32">11</d:Id>
                        <d:ID m:type="Edm.Int32">11</d:ID>
                        <d:FileRef>/path/to/some/file.ext</d:FileRef>
                    </m:properties>
                </content>
            </entry>
        </m:inline>
    </link>
    <title/>
    <updated>2018-08-27T09:58:06Z</updated>
    <author>
        <name/>
    </author>
    <content type="application/xml"/>
</entry>

The response I receive from cloud/test lab:

<entry>
    <id>http://test.domain.com/_api/Web/GetFileByServerRelativeUrl('/giltest2/aFile.doc')</id>
    <category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="SP.File"/>
    <link href="Web/GetFileByServerRelativeUrl('/giltest2/Scheduling%20Coordinator%20letter%2010-28-01%20path%2030.doc')" rel="edit"/>
    <link href="Web/GetFileByServerRelativeUrl('/giltest2/Scheduling%20Coordinator%20letter%2010-28-01%20path%2030.doc')/ListItemAllFields" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ListItemAllFields" title="ListItemAllFields" type="application/atom+xml;type=entry">
        <m:inline>
            <entry m:etag="&quot;1&quot;">
                <id>4499279f-96a5-4ec4-9a5f-c905662b79d2</id>
                <category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="SP.Data.Giltest2Item"/>
                <link href="Web/GetFileByServerRelativeUrl('/giltest2/Scheduling%20Coordinator%20letter%2010-28-01%20path%2030.doc')/ListItemAllFields" rel="edit"/>
                <title/>
                <updated>2018-08-27T14:33:19Z</updated>
                <author>
                    <name/>
                </author>
                <content type="application/xml">
                    <m:properties>
                        <d:Id m:type="Edm.Int32">1</d:Id>
                        <d:ID m:type="Edm.Int32">1</d:ID>
                        <d:FileRef>/giltest2/aFile.doc</d:FileRef>
                    </m:properties>
                </content>
            </entry>
        </m:inline>
    </link>
    <link href="Web/GetFileByServerRelativeUrl('/giltest2/Scheduling%20Coordinator%20letter%2010-28-01%20path%2030.doc')/Properties" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Properties" title="Properties" type="application/atom+xml;type=entry">
        <m:inline>
            <entry>
                <id>http://test.domain.com/_api/Web/GetFileByServerRelativeUrl('/giltest2/aFile.doc')/Properties</id>
                <category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="SP.PropertyValues"/>
                <link href="Web/GetFileByServerRelativeUrl('/giltest2/Scheduling%20Coordinator%20letter%2010-28-01%20path%2030.doc')/Properties" rel="edit"/>
                <title/>
                <updated>2018-08-27T14:33:19Z</updated>
                <author>
                    <name/>
                </author>
                <content type="application/xml">
                    <m:properties>
                        <d:vti_x005f_docstoreversion m:type="Edm.Int32">1</d:vti_x005f_docstoreversion>
                        <d:vti_x005f_metadatanextbsn>100</d:vti_x005f_metadatanextbsn>
                        <d:vti_x005f_nextbsn>150</d:vti_x005f_nextbsn>
                        <d:vti_x005f_replid>rid:{E98AEE2E-C7DD-4064-A659-7003C8042443}</d:vti_x005f_replid>
                        <d:vti_x005f_level m:type="Edm.Int32">1</d:vti_x005f_level>
                        <d:OData__x005f_PID_x005f_GUID/>
                        <d:ContentTypeId>0x010100E4308556AF5E6244BAFA30F69D58345B</d:ContentTypeId>
                        <d:vti_x005f_setuppathversion m:type="Edm.Int32">16</d:vti_x005f_setuppathversion>
                        <d:OData__x005f_Comments/>
                        <d:vti_x005f_sourcecontrolversion>V1.0</d:vti_x005f_sourcecontrolversion>
                        <d:vti_x005f_sourcecontrolcookie>fp_internal</d:vti_x005f_sourcecontrolcookie>
                        <d:Subject/>
                        <d:vti_x005f_filesize m:type="Edm.Int32">28160</d:vti_x005f_filesize>
                        <d:vti_x005f_modifiedby>SP01\administrator</d:vti_x005f_modifiedby>
                        <d:vti_x005f_title>Scheduling Coordinator:</d:vti_x005f_title>
                        <d:vti_x005f_streamschema m:type="Edm.Int32">66</d:vti_x005f_streamschema>
                        <d:vti_x005f_internalversion m:type="Edm.Int32">257</d:vti_x005f_internalversion>
                        <d:vti_x005f_categories/>
                        <d:vti_x005f_parserversion>16.0.0.4351</d:vti_x005f_parserversion>
                        <d:Keywords/>
                        <d:OData__x005f_Author>MMcQuay-OSAT</d:OData__x005f_Author>
                        <d:vti_x005f_author>SP01\administrator</d:vti_x005f_author>
                        <d:vti_x005f_foldersubfolderitemcount m:type="Edm.Int32">0</d:vti_x005f_foldersubfolderitemcount>
                        <d:vti_x005f_contentversionisdirty>false</d:vti_x005f_contentversionisdirty>
                        <d:vti_x005f_timecreated m:type="Edm.DateTime">2018-08-14T06:42:19</d:vti_x005f_timecreated>
                        <d:vti_x005f_cachedtitle>Scheduling Coordinator:</d:vti_x005f_cachedtitle>
                        <d:vti_x005f_metainfoversion m:type="Edm.Int32">1</d:vti_x005f_metainfoversion>
                        <d:vti_x005f_cachedcustomprops>vti_approvallevel vti_categories Subject vti_assignedto Keywords _Status vti_title _Author _Category _PID_GUID _Comments</d:vti_x005f_cachedcustomprops>
                        <d:vti_x005f_contenttag>{E98AEE2E-C7DD-4064-A659-7003C8042443},1,1</d:vti_x005f_contenttag>
                        <d:vti_x005f_docstoretype m:type="Edm.Int32">0</d:vti_x005f_docstoretype>
                        <d:vti_x005f_canmaybeedit>true</d:vti_x005f_canmaybeedit>
                        <d:vti_x005f_nextbsnallocated>150</d:vti_x005f_nextbsnallocated>
                        <d:OData__x005f_Status/>
                        <d:vti_x005f_folderitemcount m:type="Edm.Int32">0</d:vti_x005f_folderitemcount>
                        <d:vti_x005f_approvallevel/>
                        <d:vti_x005f_rtag>rt:E98AEE2E-C7DD-4064-A659-7003C8042443@00000000001</d:vti_x005f_rtag>
                        <d:vti_x005f_parentid>{842AE712-3024-4DD4-A3A6-0FDF105761BF}</d:vti_x005f_parentid>
                        <d:OData__x005f_Category/>
                        <d:vti_x005f_candeleteversion>true</d:vti_x005f_candeleteversion>
                        <d:vti_x005f_timelastmodified m:type="Edm.DateTime">2018-08-14T06:42:19</d:vti_x005f_timelastmodified>
                        <d:vti_x005f_contentversion m:type="Edm.Int32">1</d:vti_x005f_contentversion>
                        <d:vti_x005f_etag>&quot;{E98AEE2E-C7DD-4064-A659-7003C8042443},1&quot;</d:vti_x005f_etag>
                        <d:vti_x005f_timelastwritten m:type="Edm.DateTime">2018-08-14T06:42:19</d:vti_x005f_timelastwritten>
                        <d:vti_x005f_assignedto/>
                    </m:properties>
                </content>
            </entry>
        </m:inline>
    </link>
    <title/>
    <updated>2018-08-27T14:33:19Z</updated>
    <author>
        <name/>
    </author>
    <content type="application/xml"/>
</entry>
0

Using the REST API below to retrieve file itemId, file path, file size, file created time and last modified time. Both works in SharePoint 2013 on-premise and SharePoint Online.

/_api/web/GetFolderByServerRelativeUrl('/path/to/folder')/Files?$select=ListItemAllFields/Id,ListItemAllFields/FileRef,Length,TimeCreated,TimeLastModified&$expand=ListItemAllFields&$top=10

  • Unfortunately, that produced "empty" data answer: <?xml version="1.0" encoding="utf-8"?> <feed xml:base="http://52.36.112.60:54321/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <id>8eb97b13-49c7-4fc6-a979-384b7f8b6caf</id> <title/> <updated>2018-08-28T08:39:09Z</updated> <author> <name/> </author> </feed> – OBY Trance Aug 28 '18 at 8:41
  • remove &$skip=10 in the rest api – LZ_MSFT Aug 28 '18 at 9:16
  • Didn't do the trick :-( removed top&skip parameters. Should this call work the same on sp-online? 2016? – OBY Trance Aug 28 '18 at 10:12
  • Remove $skip=10, it works in my SharePoint Online and SharePoint 2013 on-premise test environment. – LZ_MSFT Aug 29 '18 at 1:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.