Unable to execute getchanges query from sharepoint site using REST API - 403 error RRS feed

  • Question

  • 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.

    Wednesday, May 2, 2018 9:21 AM

All replies

  • Hi,

    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.

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

    Best Regards,

    Carl Zhou

    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    • Proposed as answer by Carl__Zhou Thursday, May 10, 2018 2:21 AM
    • Unproposed as answer by Carl__Zhou Thursday, May 10, 2018 2:21 AM
    • Proposed as answer by Dean_WangModerator Thursday, May 10, 2018 2:22 AM
    Thursday, May 3, 2018 9:50 AM