SP.Web.serverRelativeUrl property (sp.js)

Gets or sets the server-relative URL for the Web site.

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

var value = SP.Web.get_serverRelativeUrl ()
var value = SP.Web.set_serverRelativeUrl ()

Return value

Type: String

A string that contains the server-relative URL.

Remarks

It must not be null. It must not contain any of the reserved URLs. It must not contain the following illegal characters: [!#$&'+:<>?\\{|}~]|(//)|(\.\.)|(/_)|(/wpresources$)|(/wpresources/).

REST resource endpoint

See Web resource for more information.

Endpoint URI structure

http://<sitecollection>/<site>/_api/web/serverRelativeUrl

HTTP requests

This resource supports the following HTTP commands:

  • POST

POST syntax

POST http://<sitecollection>/<site>/_api/web/serverRelativeUrl

GET syntax

GET http://<sitecollection>/<site>/_api/web/serverRelativeUrl