关注网站
命名空间:microsoft.graph
关注 用户网站或多个 网站。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 | 权限(从最低特权到最高特权) |
|---|---|
| 委派(工作或学校帐户) | Sites.ReadWrite.All |
| 委派(个人 Microsoft 帐户) | 不支持。 |
| 应用程序 | Sites.ReadWrite.All |
HTTP 请求
POST /users/{user-id}/followedSites/add
请求正文
在请求正文中,提供 JSON 对象数组以及下表中提到的 id 参数。
| 名称 | 值 | 说明 |
|---|---|---|
| id | string | 项的唯一标识符。 |
响应
- 如果请求成功,此方法将返回一组已关注的网站。
207如果在关注任何指定网站时发生错误,此方法将返回状态代码,响应正文将包含一组包含错误对象的条目和 siteId,用于指示无法关注哪些网站。
示例
以下示例演示如何关注多个网站。
请求
POST /users/{user-id}/followedSites/add
Content-Type: application/json
{
"value":
[
{
"id": "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,712a596e-90a1-49e3-9b48-bfa80bee8740"
},
{
"id": "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,0271110f-634f-4300-a841-3a8a2e851851"
}
]
}
响应
如果成功,它将返回以下 JSON 响应。
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"id": "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,712a596e-90a1-49e3-9b48-bfa80bee8740",
"webUrl": "http://contoso.sharepoint.com/sites/SiteFollowed1",
"name": "SiteFollowed1",
"sharepointIds": {
"siteId": "da60e844-ba1d-49bc-b4d4-d5e36bae9019",
"siteUrl": "http://contoso.sharepoint.com/sites/SiteFollowed1",
"webId": "712a596e-90a1-49e3-9b48-bfa80bee8740"
},
"siteCollection": {
"hostname": "contoso.sharepoint.com"
}
},
{
"id": "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,0271110f-634f-4300-a841-3a8a2e851851",
"webUrl": "http://contoso.sharepoint.com/sites/SiteFollowed2",
"name": "SiteFollowed2",
"sharepointIds": {
"siteId": "da60e844-ba1d-49bc-b4d4-d5e36bae9019",
"siteUrl": "http://contoso.sharepoint.com/sites/SiteFollowed2",
"webId": "0271110f-634f-4300-a841-3a8a2e851851"
},
"siteCollection": {
"hostname": "contoso.sharepoint.com"
}
}
]
}
如果发生错误,它将返回以下 JSON 响应
HTTP/1.1 207 Multi-Status
Content-type: application/json
{
"value": [
{
"id": "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,512a596e-90a1-49e3-9b48-bfa80bee8740",
"error": {
"@odata.type": "#oneDrive.error",
"code": "invalidRequest",
"message": "The site Id information that is provided in the request is incorrect",
"innerError": {
"code": "invalidRequest",
"errorType": "expected",
"message": "The site Id information that is provided in the request is incorrect",
"stackTrace": "",
"throwSite": ""
}
}
},
{
"id": "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,0271110f-634f-4300-a841-3a8a2e851851",
"webUrl": "http://contoso.sharepoint.com/sites/SiteFollowed2",
"name": "SiteFollowed2",
"sharepointIds": {
"siteId": "da60e844-ba1d-49bc-b4d4-d5e36bae9019",
"siteUrl": "http://contoso.sharepoint.com/sites/SiteFollowed2",
"webId": "0271110f-634f-4300-a841-3a8a2e851851"
},
"siteCollection": {
"hostname": "contoso.sharepoint.com"
}
}
]
}
反馈
提交和查看相关反馈