取消关注网站
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
取消关注 用户网站或多个 网站。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Sites.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持。
应用程序
Sites.ReadWrite.All
HTTP 请求
POST /users/{user-id}/followedSites/remove
请求正文
在请求正文中,提供 JSON 对象数组以及下表中提到的 id 参数。
名称
值
说明
id
string
项的唯一标识符 。
响应
如果请求成功,此方法返回无 204 内容的状态代码。
207如果在取消关注任何指定网站时发生错误,此方法将返回状态代码,响应正文将包含一组包含 error 对象和 siteId 的条目,这些条目指示哪些网站无法取消处理。
示例
以下示例演示如何取消关注多个网站。
请求
POST /users/{user-id}/followedSites/remove
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"
}
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var value = new List<Site>()
{
new Site
{
Id = "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,712a596e-90a1-49e3-9b48-bfa80bee8740"
},
new Site
{
Id = "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,0271110f-634f-4300-a841-3a8a2e851851"
}
};
await graphClient.Users["{user-id}"].FollowedSites
.Remove(value)
.Request()
.PostAsync();
const options = {
authProvider,
};
const client = Client.init(options);
const site = {
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'
}
]
};
await client.api('/users/{user-id}/followedSites/remove')
.version('beta')
.post(site);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/users/{user-id}/followedSites/remove"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
NSMutableArray *valueList = [[NSMutableArray alloc] init];
MSGraphSite *value = [[MSGraphSite alloc] init];
[value setId:@"contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,712a596e-90a1-49e3-9b48-bfa80bee8740"];
[valueList addObject: value];
MSGraphSite *value = [[MSGraphSite alloc] init];
[value setId:@"contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,0271110f-634f-4300-a841-3a8a2e851851"];
[valueList addObject: value];
payloadDictionary[@"value"] = valueList;
NSData *data = [NSJSONSerialization dataWithJSONObject:payloadDictionary options:kNilOptions error:&error];
[urlRequest setHTTPBody:data];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Site> valueList = new LinkedList<Site>();
Site value = new Site();
value.id = "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,712a596e-90a1-49e3-9b48-bfa80bee8740";
valueList.add(value);
Site value1 = new Site();
value1.id = "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,0271110f-634f-4300-a841-3a8a2e851851";
valueList.add(value1);
SiteCollectionResponse siteCollectionResponse = new SiteCollectionResponse();
siteCollectionResponse.value = valueList;
SiteCollectionPage siteCollectionPage = new SiteCollectionPage(siteCollectionResponse, null);
graphClient.users("{user-id}").followedSites()
.remove(SiteRemoveParameterSet
.newBuilder()
.withValue(valueList)
.build())
.buildRequest()
.post();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.New()
requestBody.SetAdditionalData(map[string]interface{}{
"value": []Object {
}
}
userId := "user-id"
siteId := "site-id"
graphClient.UsersById(&userId).FollowedSitesById(&siteId).Post(requestBody)
响应
如果成功,它将返回以下 JSON 响应。
HTTP/1.1 204 No Content
如果发生错误,它将返回以下 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": ""
}
}
}
]
}