最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

azure - MS Graph API - List getting all views for Sharepoint list - Stack Overflow

programmeradmin6浏览0评论

I am hoping I am just missing something in the documentation but I am trying to get a listing of all of the views for a SharePoint List. I have one with 4 or 5 custom views and when I search for guidance outside of the standard API docs it says to use this format:

GET /sites/{site-id}/lists/{list-id}/views

However, that returns a 400 Error since it is doesn't appear to be a valid GET option.

Is there Web url query instead that should be used?

I know this must be possible as we have an automation tool called Alteryx that was able to pull back all of the available view for a list, somehow, programmatically.

I am hoping I am just missing something in the documentation but I am trying to get a listing of all of the views for a SharePoint List. I have one with 4 or 5 custom views and when I search for guidance outside of the standard API docs it says to use this format:

GET /sites/{site-id}/lists/{list-id}/views

However, that returns a 400 Error since it is doesn't appear to be a valid GET option.

Is there Web url query instead that should be used?

I know this must be possible as we have an automation tool called Alteryx that was able to pull back all of the available view for a list, somehow, programmatically.

Share Improve this question edited Mar 25 at 4:01 Rukmini 16.6k2 gold badges8 silver badges21 bronze badges Recognized by Microsoft Azure Collective asked Mar 25 at 2:37 user2232552user2232552 1521 gold badge1 silver badge10 bronze badges 2
  • Please check below solution! and let me know it works for you or not? @user2232552 – Pratik Jadhav Commented Mar 25 at 8:31
  • Any update on the issue?@user2232552 – Pratik Jadhav Commented Mar 28 at 5:35
Add a comment  | 

2 Answers 2

Reset to default 0

As far as I know, the Microsoft Graph has no support for listing, creating, or updating SharePoint list views. The APIs you could use instead are the SharePoint REST API or the SharePoint Client Object Model (CSOM).

Agree with @Rob Windsor, Microsoft Graph API doesn't supports listing, creating, or updating SharePoint list views.

I got same error, When I generated the access token with scopes of https://graph.microsoft/.default and Use the same token for GET /sites/{site-id}/lists/{list-id}/views using Microsoft Graph API.

To resolve this you need to use SharePoint REST API.

Initially, I registered Single Tenant Microsoft Entra ID Application, Added delegated type AllSites.FullControl SharePoint API permission and Granted Admin Consent like below:

Using delegated type, authorization_code flow which requires user-interaction. To get code, I ran below authorization request in browser:

https://login.microsoftonline/<tenant_id>/oauth2/v2.0/authorize?  
client_id=<client_id>
&response_type=code  
&redirect_uri=https://jwt.ms
&response_mode=query  
&scope=https://microsoft.sharepoint/.default
&state=12345

After successfully creating authorization_code, Generated access token using below parameters:

POST https://login.microsoftonline/<tenant-id>/oauth2/v2.0/token


client_id: <application-id>
client_secret: <client-secret>
scope: https://microsoft.sharepoint/.default
grant_type: authorization_code
code: <authorization_code generated from browser>
redirect_uri: <REDIRECT_URI>

Response:

Now, Use the same access token for List getting all views for Sharepoint list:

GET https://{your-site}/_api/web/lists/getbyid('{list-id}')/views

Response:

Reference:

SharePoint REST API

发布评论

评论列表(0)

  1. 暂无评论