SharePoint fields with RESTClient
This script can be used to test connectivity, pathing, and to collect the complete set of fields for a library.
Tools like Powershell or Postman will support making Graph API requests. You can also use plugins to VS Code for quick testing and pulling of data. REST Client for VS Code has > 6 million downloads and is easy to use for quick tests.
@tenantId = YourTenantIdHere
@clientId = YourClientIdHere
@clientSecret = YourClientSecretHere
@url = https://graph.microsoft.com/v1.0
@sitePath = <site>.sharepoint.com:/sites/<Path>
@listName = YourListNameHere
@token = {{auth.response.body.$.access_token}}
### 1. Authenticate (client credentials)
# @name auth
POST https://login.microsoftonline.com/{{tenantId}}/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&client_id={{clientId}}&client_secret={{clientSecret}}&scope=https://graph.microsoft.com/.default
### 2. Resolve the site id
# @name GetSite
GET {{url}}/sites/{{sitePath}}
Authorization: Bearer {{token}}
### 3. List all libraries/lists on the site -> confirm the exact displayName for @listName
# @name GetLists
GET {{url}}/sites/{{GetSite.response.body.$.id}}/lists?$select=id,name,displayName
Authorization: Bearer {{token}}
### 4. Resolve the list id by display name
# @name GetListByName
GET {{url}}/sites/{{GetSite.response.body.$.id}}/lists?$select=id,name,displayName&$filter=displayName eq '{{listName}}'
Authorization: Bearer {{token}}
### 5. Field/column names (name = internal name, displayName = UI label)
# @name GetListColumns
GET {{url}}/sites/{{GetSite.response.body.$.id}}/lists/{{GetListByName.response.body.$.value[0].id}}/columns?$select=name,displayName,columnGroup,readOnly
Authorization: Bearer {{token}}