Logo
  • Contact form
  • Events & slides
  • Buy me a snack
👋🏻
/
📝
All Blogs
/HTTP Request for SharePoint - Site structure
HTTP Request for SharePoint - Site structure
HTTP Request for SharePoint - Site structure

HTTP Request for SharePoint - Site structure

Table of contents

  • Hub site and its children
  • Getting a site id
  • Site columns
  • Lists
  • Get the relative url of a list
  • Create list or modify list settings
  • Deleting a list
  • List fields
  • Create list fields
  • Delete list columns
  • Content types
  • Get all list content types
  • Create list content type
  • Modify existing list content type
  • Enable modern form for document sets
  • Content type fields
  • Get list content type fields
  • Remove list content type fields
  • Views
  • Get list views
  • List view fields
  • Changelog
☝
TL;DR - The SharePoint API is not only great to update items or set permissions, you can also use it to either read or create site structure and copy lists from one to another site collection. I will add more once I use them actively.

Hub site and its children

Getting a site id

This return an id property that contains three parts separated by commas. The second value is the site id.

_api/v2.0/sites/tenant.sharepoint.com:/sites/Training:/

Site columns

Method: GET
Uri: _api/web/fields

Result: body('ACTIONNAME')?['d']?['results']

Lists

Something to look out for is the BaseType, 0 = List, 1 = Library

Sadly, this endpoint does not directly support filtering. You could use something like “GetByTitle(’SitePages’)” instead.

Method: GET
//all lists
Uri: _api/web/lists

//specific list
_api/web/lists('LIST GUID')
Uri: 
Headers:
{
  "accept": "application/json;odata=verbose",
  "content-type ": "application/json;odata=verbose"
}

Result: body('ACTIONNAME')?['d']?['results']
‣
Output (redacted)

Get the relative url of a list

Method: GET
Uri: _api/web/lists('LIST GUID')?$select=Id,Title,RootFolder/ServerRelativeUrl&$expand=RootFolder

Result: body('HTTP ACTION NAME')?['d/RootFolder/ServerRelativeUrl']
‣
Response sample

Create list or modify list settings

All list settings can be found here: SP.List object | Microsoft Learn

BaseTemplate 100 = List, 101 = Library

Adding these exact headers is very important!

Deleting a list

Method: DELETE
Uri: _api/web/lists('LISTGUID')
Headers: 
{
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose"
}

List fields

Something to look out for is the StaticName property. This shows the fields internal name.

Method: GET
Uri: _api/web/lists(guid'LISTGUID')/fields

//also works with select and filter
_api/web/lists(guid'LISTGUID')/fields?$select=__metadata,Title,FieldTypeKind,Required,EnforceUniqueValues,StaticName,Hidden&$filter=Hidden eq false
_api/web/lists/getByTitle('My list')/fields?$select=id,Title

Result: body('ACTIONNAME')?['d']?['results']

Create list fields

‣
Field Type Kind

Delete list columns

Sometimes the action will return an error saying that the field cannot be found, this is wrong. If you can see in the UI, its there. In that case you will need to use the field id instead of the title. To do that

Content types

Get all list content types

Supports: Select, Filter

Method: GET
Uri: _api/web/Lists('LISTGUID')/ContentTypes

Result: body('ACTIONNAME')?['d']?['results']

Create list content type

Method: POST
Uri: _api/web/Lists(guid'LISTGUID')/ContentTypes

Body:
{
  "__metadata": {
    "type": "SP.ContentType"
  },
  "Name": "New Content Type",
  "Description": "New Content Type Description",
  "Group": "Custom Content Type Group"
}

Modify existing list content type

Enable modern form for document sets

🚨

THIS IS NOT REVERSIBLE. As this a change on library level, the only way to undo this change is to delete the content type from the library and add it again. Make sure this is well thought out, best case would be to do this right at the beginning of whatever you are building.

Content type fields

Get list content type fields

This would be part of a loop based on listing the content types.

Method: GET
Uri: _api/web/Lists('LIST GUID')/ContentTypes('item()?['StringId']}')/fields

Result: body('ACTIONNAME')?['d']?['results']

Remove list content type fields

Seems like its not possible now. I tried this:

Method: POST
Uri: _api/web/Lists('LIST GUID')/ContentTypes('item()?['StringId']}')/fields/getbyid('FIELD ID')

Headers:
{
  "Accept": "application/json;odata=verbose",
  "Content-Type": "application/json;odata=verbose",
  "IF-MATCH": "*",
  "X-HTTP-Method": "DELETE"
}

Views

Get list views

Method: GET
Uri: _api/web/lists(guid'LISTGUID')/Views
Result: body('ACTIONNAME')?['d']?['results']

//to get the default view and its id
Uri: _api/web/lists(guid'LISTGUID')/Views?$filter=DefaultView eq true
Result: first(body('ACTIONNAME')?['d']?['results'])?['Id']
‣
List view response (redacted and shortened)

List view fields

This would be a part of a loop based on listing the views.

Method: GET
Uri: _api/web/lists(guid'LISTGUID')/Views(guid'item()?['Id']')/ViewFields

Result: body('ACTIONNAME')?['d']?['results']

Changelog

Date
Changes
07.09.2025
Added remove field from list content type, not possible atm.
27.02.2026
Get the relative url of a list with example output

Thanks for reading! 💕

Logo

Events & slides

Buy me a snack

Contact form

Data privacy policy

About

This blog is made with ♥️ on Notion and made public with Super.so. Rocket icon created by RIkas Dzihab - Flaticon.

RedditLinkedIn
//first get the hubsiteid
Method: GET
Uri: /_api/site?$select=IsHubSite,HubSiteId

Result: body('Send_an_HTTP_request_to_SharePoint_-_Hub_Site_Id')?['d']?['HubSiteId']

//use result in another http action, by default the api will return a paged array. Using the top parameters gives you all sites in a single array. The service limit for assigning children to a hub is 500.
_api/v2.1/sites?$filter=sharepointIds/hubSiteId eq 'HUBSITEID'&$top=500
//Create list
Method: POST
Uri: _api/web/lists
Headers: 
{
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose"
}
Body: 
{
  "__metadata": {
    "type": "SP.List"
  },
  "AllowContentTypes": true,
  "BaseTemplate": 100,
 "ContentTypesEnabled": true,
 "Description": "My list description",
 "Title": "Test"
}

//Modify list settings
Method: POST
Uri: _api/web/lists('LIST GUID')
Headers: 
{
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"If-Match": "*",
"X-HTTP-Method": "MERGE"
}
Body: 
{
  "__metadata": {
    "type": "SP.List"
  },
  "AllowContentTypes": true,
  "BaseTemplate": 100,
 "ContentTypesEnabled": true,
 "Description": "My list description",
 "Title": "Test"
}
Method: POST
Uri: _api/web/lists(guid'LISTGUID')/fields
Headers: 
{
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose"
}
Body:
{
"__metadata":
	{
	"type": "SP.Field"
	},
	"FieldTypeKind": 2,
	"Title":"DisplayName",
	"StaticName":"InternalName",
	"Required": true,
	//Datetime column (DateOnly = 0, DateTime = 1)
	"DisplayFormat": 0,
	//Choice values or column formatting
	"SchemaXml": "Xml",
	"ReadOnlyField":false
}
Method: POST
Uri: _api/web/lists/getByTitle('My list')/fields/getbytitle('My column')

With field id: _api/web/lists/getByTitle('Planner Kanban')/fields/getbyid('field guid')

Headers:
{
  "Accept": "application/json;odata=verbose",
  "Content-Type": "application/json;odata=verbose",
  "IF-MATCH": "*",
  "X-HTTP-Method": "DELETE"
}
Method: POST
Uri: _api/web/Lists('LISTGUID')/ContentTypes('CONTENTTYPEID')
Headers: 
{
  "Accept": "application/json;odata=verbose",
  "Content-Type": "application/json;odata=verbose",
  "If-Match": "*",
  "X-HTTP-Method": "MERGE"
}

Body:
{
  "__metadata": {
    "type": "SP.ContentType"
  },
  "Name":"New Name"
  "NewFormClientSideComponentId": ""
}