Create SharePoint List Using Microsoft Graph Explorer In Office 365

Microsoft Graph Explorer is a browser-based REST API client for Office 365. By using Graph explorer, we can access all applications/services in Microsoft Cloud by sending the Microsoft Graph API request.

Microsoft Graph API is a single endpoint with single authentication to access all Microsoft cloud services like Office 365 (OneDrive, SharePoint, etc..), Windows and Enterprise + Mobility.

Here, we are going to see on how to create a list in SharePoint Online using Microsoft Graph Explorer.

Authenticate and Permission Setup

  • Navigate to Graph Explorer https://developer.microsoft.com/en-us/graph/graph-explorer
  • Authenticate with Office 365 account by using Sign in with Microsoft button

    SharePoint

Note: Graph Explorer also works with sample data, if you are not authenticated. To access the actual information, you have to sign in to the Office 365.

  • After Authentication, the Sign in with Microsoft button is replaced by account information.

    SharePoint

  • The user should need permission to create a list. So, we have to ensure that Manage All Permission is selected in Graph Explorer permissions.

  • To ensure the permission, click modify permissions Then select Site.Manage.All checkbox and click on Modify Permissions button.

    SharePoint

  • This will automatically logout and login to the Microsoft Graph Explorer. Before auto signing in, the application asks us to accept the permission scope.

    SharePoint

  • Click Accept button to accept the application to manage the lists in SharePoint Site Collections.

Graph Explorer

Now, we are ready for creating List.

  • Select the Post method from the method drop-down.
  • Enter the below Graph endpoint, https://graph.microsoft.com/v1.0/sites/ktskumar.sharepoint.com:/sites/dev:/lists

    SharePoint

  • Enter the Request body in the below format
    1. {  
    2.     "displayName""GraphList",  
    3.     "list": {  
    4.         "template""genericList"  
    5.     }  
    6.     6.  
    • displayName – Title for the list
    • list: variable for declaring list settings
    • template: child variable under list, refers to the list template type
  • Ensure the Request header as below,

    • Key - Content-Type
    • Value - application/json

  • Then, click on Run Query button to send the request to create a new list called “GraphList” under https://ktskumar.sharepoint.com/site/dev

Output

After sending the request, our request will create a new list under the provided SharePoint site. Response Preview control shows the output in JSON format as provided below.

  1. {  
  2.     "@odata.context""https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.list)/$entity",  
  3.     "@odata.etag""\"f5fe8ccd-df1f-4aec-80d8-b375f650af9e,8\"",  
  4.     "createdDateTime""2018-06-26T11:06:39Z",  
  5.     "description""",  
  6.     "eTag""\"f5fe8ccd-df1f-4aec-80d8-b375f650af9e,8\"",  
  7.     "id""f5fe8ccd-df1f-4aec-80d8-b375f650af9e",  
  8.     "lastModifiedDateTime""2018-06-26T11:06:39Z",  
  9.     "name""GraphList",  
  10.     "webUrl""https://ktskumar.sharepoint.com/sites/dev/Lists/GraphList",  
  11.     "displayName""GraphList",  
  12.     "createdBy": {  
  13.         "user": {  
  14.             "email""[email protected]",  
  15.             "id""4dccf644-24fd-4500-bb7f-311a4216bb73",  
  16.             "displayName""Shantha Kumar"  
  17.         }  
  18.     },  
  19.     "parentReference": {},  
  20.     "list": {  
  21.         "contentTypesEnabled"false,  
  22.         "hidden"false,  
  23.         "template""genericList"  
  24.         24.  
  25.     }  
  26.     25.  
  27. }  

After navigation to the SharePoint site https://ktskumar.sharepoint.com/sites/dev in a browser; we can view the newly created list “GraphList” present under the site.

 Create List with Custom Columns

To create a custom list with the custom columns, alter the Request body in the below format. Add any column types under columns array in JSON.

  1. {  
  2.     "displayName""GraphList",  
  3.     "columns": [{  
  4.         "name""Service",  
  5.         "text": {}  
  6.     }, {  
  7.         "name""AppCount",  
  8.         "number": {}  
  9.     }],  
  10.     "list": {  
  11.         "template""genericList"  
  12.         15.  
  13.     }  

Columns

Array variable to have column information (name, <type>, …).

The above request will create a SharePoint list called ‘GraphList’ with two additional custom columns (service as a Single line of Text and AppCount as Number)

Method - POST

Request Body

  1. {  
  2.   "displayName""GraphList2",  
  3.   "list": {  
  4.     "template""genericList"  
  5.   }  
  6. }  

Request Header

  • Key - Content-Type
  • Value - application/json

Response

  1. {  
  2.     "@odata.context""https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.list)/$entity",  
  3.     "@odata.etag""\"f5fe8ccd-df1f-4aec-80d8-b375f650af9e,8\"",  
  4.     "createdDateTime""2018-06-26T11:06:39Z",  
  5.     "description""",  
  6.     "eTag""\"f5fe8ccd-df1f-4aec-80d8-b375f650af9e,8\"",  
  7.     "id""f5fe8ccd-df1f-4aec-80d8-b375f650af9e",  
  8.     "lastModifiedDateTime""2018-06-26T11:06:39Z",  
  9.     "name""GraphList",  
  10.     "webUrl""https://ktskumar.sharepoint.com/sites/dev/Lists/GraphList",  
  11.     "displayName""GraphList",  
  12.     "createdBy": {  
  13.         "user": {  
  14.             "email""[email protected]",  
  15.             "id""4dccf644-24fd-4500-bb7f-311a4216bb73",  
  16.             "displayName""Shantha Kumar"  
  17.         }  
  18.     },  
  19.     "parentReference": {},  
  20.     "list": {  
  21.         "contentTypesEnabled"false,  
  22.         "hidden"false,  
  23.         "template""genericList"  
  24.     }  
  25. }  

SharePoint

After navigation to the SharePoint site at URL https://ktskumar.sharepoint.com/sites/dev, we can see the newly created list called GraphList.

If, we want to create a new list with columns, send the request body as,

  1. {  
  2.   "displayName""GraphList",  
  3.    "columns": [  
  4.     {  
  5.       "name""Service",  
  6.       "text": { }  
  7.     },  
  8.     {  
  9.       "name""AppCount",  
  10.       "number": { }  
  11.     }  
  12.   ],  
  13.   "list": {  
  14.     "template""genericList"  
  15.   }