How Do I Change The Project Owner Using REST API

本小妞迷上赌 提交于 2020-03-27 08:48:30

问题


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

  1. Start by checking out the project
  2. 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 project

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

  3. Publish the project



来源:https://stackoverflow.com/questions/41951805/how-do-i-change-the-project-owner-using-rest-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!