HTTP 403 Forbidden error for getchanges SharePoint REST API call

New Contributor

Hi, 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:

And the item payload is passed as follows:

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

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:

I'm getting 403 forbidden error as response:

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

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.

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

Kindly help.

2 Replies
Out of curiosity: why do you want to use RET API in your console application? With CSOM you are going to be much more productive and get the data you need

Hello Juan,

Thank you for your reply. Our team's view is that if we build our product using REST API, we can be flexible to adopt to different environments and also avoid dependencies on specific sharepoint assemblies (like Microsoft.SharePoint.Client.dll ) . If I cannot resolve my ChangeQuery call using REST, then we would go for CSOM.