问题
I want to change the project owner of a project using REST API. I know there is a "/Owner" endpoint and I can get the owner without any problems with the following GET:
site/_api/ProjectServer/Projects('2cc734f2-cd16-4f09-8632-a2bc74a32577')/Owner
So how do I change the project owner using REST API?
回答1:
The general way to change site owners using REST API according to MSDN is:
POST http://<sitecollection>/<site>/_api/site/owner
So in your case you should just have to change from a GET command to POST
回答2:
This is an old issue but I figured it might help someone since I recently struggeled with this too. I have only tested this on Project Online and not on-prem, probably works the same on Project Server 2016
- Start by checking out the project
Send a PATCH request to:
_api/ProjectServer/Projects('PROJECT ID')/Draft
with the following headers:
Accept: application/json; odata=verbose
Content-Type: application/json; odata=verbose
X-RequestDigest: The request digest
If-Match: Either "*" or the etag value you get from checking out the projectand the request body:
{ "__metadata": { "type": "PS.DraftProject" }, "OwnerId": "SharePoint User ID of the owner" }
It's important that you send the "OwnerId" value as a string, not a number.
Publish the project
来源:https://stackoverflow.com/questions/41951805/how-do-i-change-the-project-owner-using-rest-api