AnswerBun.com

SharePoint 2013 get full file name including extension

SharePoint Asked by Adam13Hylo on November 5, 2021

Wondering if anyone can help me please, I have a media library with a number of videos in and I want to get the full file name including the extension out of the library, I have so far tried using REST and also using CSOM, here is my REST query:

    $.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Videos')/items(" + id[ic] + ")",
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (data) {
        // Returning the results
        console.log(data);

    },
    error: function (data) {
        failure(data);
    }
    });

I have tried using the uri, the absolute encoded uri, the fileref however I only get back the file name with out the extension, for instance I want: My video.mp4 however I am only getting back My Video

Any help with this would be greatly appreciated!

3 Answers

it's worked for me

?$select=ID,Title,Description,FileRef,ContentTypeId,VideoSetDefaultEncoding,ContentType/Name&$expand=ContentType&$top=20000

Answered by Oleg Lysov on November 5, 2021

Try the below REST End point,

_spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Videos')/items?files?$filter=Id eq 1&$select=File$expand=File"

or

_spPageContextInfo.webAbsoluteUrl +"/_api/web/lists/getbytitle('Videos')/getitembyid(1)?$select=File&$expand=File"

Get the file name with extension by accessing Name property and url property by accessing ServerRelativeUrl

Answered by Shantha Kumar Thambidurai on November 5, 2021

use /_api/web/lists/getbytitle('Videos')/Files and you should be able to get the file name and extension

Answered by Ahmed Mahmoud on November 5, 2021

Add your own answers!

Related Questions

SSL for sharepoint wildcard with SANS

1  Asked on October 25, 2021 by ruby-trustit

   

MOSS – Event ID 5785 repeats every 5 min in the Event Viewer

1  Asked on October 25, 2021 by savantprodigy

 

Field not found exception

2  Asked on October 25, 2021 by denis-bednov

   

Mapping drive connection problem

1  Asked on October 25, 2021 by ahmed-aborady

     

How to create an email reminder in Sharepoint 2013

2  Asked on October 25, 2021 by cristian-badea

 

Microsoft Graph/Sharepoint API search

1  Asked on October 25, 2021 by elb98rm

       

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir