0

I am trying to update some properties of an object using the REST interface.

I am able to read the information with the GET request, but when I'm PATCH-ing (MERGE-ing) I always get a 403 Forbidden error.

I am totally new to the REST interface, and frankly, I didn't find any information or example regarding a project server payload or any example for that matter.

This is how the JSON data looks when I GET it from the server:

{
  -d: {
      -__metadata: {
        .........
       }
       ActualFinish:0001-01-01T00:00:00
       ActualOvertime: null
       ...
       PercentComplete: 0 (this is what I want to change to 100)
       ...
      }
}

This is how my payload looks right now:

{d:PercentComplete=100}

It's not working. How the normal payload should look? Do I need any additional headers, other than the

Accept: application/json;odata=verbose

As I said, I didn't find an example for these kind of updates.

1 Answer 1

1

You need three additional headers:

  1. "X-RequestDigest":"value"
    A unique security token to validate your requests.
  2. "X-HTTP-Method": "MERGE"
    To indicate that you're performing an update
  3. "If-Match":*
    To handle concurrent requests. This actually has 2 values viz. item.__metadata.etag representing the actual item tag and * to handle any value.

As an example refer to this excellent answer by Vadim: SharePoint 2013 REST api to update list item- Uncaught ReferenceError: etag is not defined

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.