SP.File.serverRelativeUrl property (sp.js)

Gets the relative URL of the file based on the URL for the server.

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

var value = SP.File.get_serverRelativeUrl ()

Return value

Type: String


The ServerRelativeUrl property returns a string in the following form, which excludes the name of the server or root folder: /Site_Name/Subsite_Name/Folder_Name/File_Name.

It must not be null. It must be a URL of server relative form.

REST resource endpoint

See File 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/folders/getbyurl(folderrelativeurl)/files/getbyurl(filerelativeurl)/serverRelativeUrl

GET syntax

GET http://<sitecollection>/<site>/_api/web/folders/getbyurl(folderrelativeurl)/files/getbyurl(filerelativeurl)/serverRelativeUrl