如何使用 REST API 更改项目所有者 [英] How Do I Change The Project Owner Using REST API
问题描述
我想使用 REST API 更改项目的项目所有者.我知道有一个/Owner"端点,我可以获取所有者,使用以下 GET 没有任何问题:
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
那么我如何更改使用 REST API 的项目所有者?
So how do I change the project owner using REST API?
推荐答案
这是一个老问题,但我认为它可能对某人有所帮助,因为我最近也在为此苦苦挣扎.我只在 Project Online 上测试过这个,没有在本地测试过,可能在 Project Server 2016 上工作得一样
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
- 首先检查项目
发送 PATCH 请求到:
- Start by checking out the project
Send a PATCH request to:
_api/ProjectServer/Projects('PROJECT ID')/草稿
_api/ProjectServer/Projects('PROJECT ID')/Draft
具有以下标题:
接受:application/json;odata=详细
内容类型:应用程序/json;odata=详细
X-RequestDigest:请求摘要
If-Match:*"或您从项目中获得的 etag 值
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 project
和请求正文:
{__元数据":{类型":PS.DraftProject"},"OwnerId": "所有者的 SharePoint 用户 ID"
{ "__metadata": { "type": "PS.DraftProject" }, "OwnerId": "SharePoint User ID of the owner" }
将OwnerId"值作为字符串而不是数字发送很重要.
It's important that you send the "OwnerId" value as a string, not a number.
发布项目
这篇关于如何使用 REST API 更改项目所有者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!