May 02 2018 01:19 AM
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:
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 } };
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://site2.sharepoint.com/sites/customer1/_api/web/getchanges
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.
May 02 2018 04:54 AM
May 02 2018 06:44 AM
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.
Thanks,
senthil