I tried to create a RESTful call that can be invoked by Angular/JavaScript command to load all data from a csv file or json file and dump them in javascript arrays

I tried


From returned contents it is able to find items but nothing regarding file name. but file id like


And if I use


it returned 'Cannot find resource for the request GetFileByServerRelativeUrl'

Is there a better way to load data file from library to javascript object?

PS: the reason I have to use document is because SharePoint list has limit of 20k rows. I have a lot rows to load.

1 Answer 1


You can use the REST API "/_api/Web/GetFileByServerRelativeUrl('/sites/mysite/test/JS File.js')/$value"to read data from js/csv files in the Document Library.

An example:

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>

<script type="text/javascript">
    $(function () {
        // begin work to call across network
        var requestUri = _spPageContextInfo.webAbsoluteUrl +
                      "/_api/Web/GetFileByServerRelativeUrl('/sites/mysite/test/JS File.js')/$value";

        // execute AJAX request
            url: requestUri,
            type: "GET",
            headers: { "ACCEPT": "application/json;odata=verbose" },
            success: function (data) {                 
            error: function () {
                alert("Failed to get details");

My test result:

enter image description here

Your Answer

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

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