3

after check in a file using rest api , it having approval status as 'draft', do we have any rest api url (postman) to update approval status of a file in share point.

2 Answers 2

3

HTTP POST:

https://<org>.sharepoint.com/sites/dev/_api/web/lists/getByTitle('list title')/items(<item id>)

Payload:

{
    "__metadata": {
        "type": "SP.Data.ClientsListItem" // your might be different
    },
    "OData__ModerationStatus": 0,
    "OData__ModerationComments": "Approved by <user name>"
}

To find out your list's type you can issue http get to https://<org>.sharepoint.com/sites/dev/_api/web/lists/getByTitle('<list title>')?$select=ListItemEntityTypeFullName. You should also provide x-requestdigest in http headers, since it's POST request.

or change moderation status with pnpjs library:

sp.web.lists.getByTitle('Clients').items.getById(1).update({
            'OData__ModerationStatus' : 0, // 1 - rejected
            'OData__ModerationComments': `Approved by <user name>`
}).then(data => {
    console.log(data);
});
3
  • Sergei => I am trying to update using Java (Rest API) Commented Nov 20, 2018 at 17:50
  • Then just ignore the part about pnpjs :). I've added just for future reference if somebody uses javascript. Commented Nov 20, 2018 at 17:54
  • Thanks Sergei it works . I have just added one more answer with screen sort and my findings. Hope it will help some one. Commented Nov 22, 2018 at 14:56
1

As told by Sergei Sergeev. We can change approval status of a file using Rest.
1. post request header.
We need all these parameters in header. (if access token have fullControl as permission then we even don't need x-requestdigest in header)

Accept: application/json;odata=verbose
Authorization: Bearer <Your access token> 
Content-Type: application/json;odata=verbose
X-HTTP-Method: MERGE
If-Match: *

enter image description here


2. post request body enter image description here

As you can see i got response as 204 - that's success. so after post above post request check your share point site.

1
  • 1
    BTW if you use bearer tokens, then you don't need request digest at all. Commented Nov 23, 2018 at 17:11

Your Answer

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

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