无法使用REST API从SharePoint网站执行getchanges查询-403错误 [英] Unable to execute getchanges query from sharepoint site using REST API - 403 error

查看:107
本文介绍了无法使用REST API从SharePoint网站执行getchanges查询-403错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'm new to sharepoint and stuck with the below issue:

Objective: To query for changes (updated or deleted list items) from Sharepoint online sites using REST API from a C# Console application.

I tried to construct below URL using HTTP Post:

https:// _ api/web /getchanges

https://site1.sharepoint.com/_api/web/getchanges

并按以下方式传递项目有效负载:

And the item payload is passed as follows:

     var itemPayload = new {query = new { __metadata = new {type ="SP.ChangeQuery" },
Update=true,Item=true } };

site1 ",但是,当我尝试对"site2"进行相同操作时, 在网站集下有很多子网站,如下所示:

The above code works fine for "site1", however, when I try the same for "site2", which has bunch of sub sites under site collection like below:

https://网站/客户1 /_ api/web/getchanges

https://site2.sharepoint.com/sites/customer1/_api/web/getchanges

我收到403禁止错误作为响应:

I'm getting 403 forbidden error as response:

{StatusCode: 403, ReasonPhrase: 'FORBIDDEN', Version: 1.1, Content: ..}

该呼叫正常运行.我路过 REST查询和CSOM的用户凭据相同.

这引起了我的问题,即我的用户凭证是否需要任何特殊的权限"?得到改变"使用REST(或)是否对我的方法做任何错误的事情.

However, when I tried ChangeQuery using CSOM library, the call works fine. I am passing the same user credentials for both REST query and CSOM.

This leads to my question whether my user credential require any special "permission" to get "changes" using REST (or) whether I'm doing anything wrong with my approach.

我查看了其他论坛帖子,但是找不到类似于site2的解决方案.

I looked into other forum posts, but I could not find out solutions similar to site2.

推荐答案

关于此问题,是由摘要引起的.

About this issue, it's caused by the digest.

您在代码中得到摘要了吗?

Did you get the digest in your code?

您需要获取摘要,然后,您可以在代码中获得用户权限.

You need to get the digest, after that, you can get the user permission in your code.

这是有关如何通过HTTPClient使用SharePoint REST的参考.

This is a reference about how to use SharePoint REST using HTTPClient.

https://piyushksingh.com/2016/12/26/sharepoint-rest- api-c/

最好的问候,

周卡尔


这篇关于无法使用REST API从SharePoint网站执行getchanges查询-403错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆