SP.Web.getFileByServerRelativeUrl Method (sp.js)

Returns the file object located at the specified server-relative URL.

Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013



  • serverRelativeUrl
    Type: String

    A string that specifies the server-relative URL for the file.

Return value

Type: SP.File

The file object.


It must not be null. It must not be empty.

REST resource endpoint

See Web resource for more information.

Endpoint URI structure


HTTP requests

This resource supports the following HTTP commands:

  • POST

POST syntax

POST http://<sitecollection>/<site>/_api/web/getFileByServerRelativeUrl(serverRelativeUrl)

Resource parameters

  • serverRelativeUrl