Sharepoint - How to get the Display Form URL, using REST

How to get List Form Url using REST API

Endpoint: /_api/web/lists/GetByTitle('<list title>')/Forms?$select=ServerRelativeUrl&$filter=FormType eq <formtypeid>

where <formtypeid> is form type.

For example, the following request returns Display Form Url for a Calendar list:

/_api/web/lists/GetByTitle('Calendar')/Forms?$select=ServerRelativeUrl&$filter=FormType eq 4

Example

function getListItemFormUrl(webUrl, listName,listItemId, formTypeId,complete, failure) {
    $.ajax({
        url: webUrl + "/_api/web/lists/GetByTitle('" + listName + "')/Forms?$select=ServerRelativeUrl&$filter=FormType eq " + formTypeId,
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
            var url = data.d.results[0].ServerRelativeUrl + '?ID=' + listItemId
            complete(url); 
        },
        error: function (data) {
            failure(data);
        }
    });
}


//Usage
getListItemFormUrl(_spPageContextInfo.webAbsoluteUrl,'Calendar',1,4,
function(url){
     console.log('Display from url for list item: ' + url);
},
function(sender, args)
{
      console.log(JSON.stringify(error));
});

Tags:

Rest