user: activateServicePlan (已弃用)
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
注意
activateServicePlan API 已弃用,将于 2022 年 6 月 30 日停止返回数据。
使用给定 servicePlanId 用户和 skuId 给定用户激活服务计划。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最高特权到最低特权)
委派(工作或学校帐户)
Directory.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持。
应用程序
Directory.ReadWrite.All
HTTP 请求
POST /users/{id | userPrincipalName}/activateServicePlan
名称
说明
Authorization
Bearer {token}。必需。
Content-Type
application/json. Required.
请求正文
在请求正文中,提供具有以下参数的 JSON 对象:
参数
类型
说明
servicePlanId
Guid
要激活的 ServicePlan 的 PlanId。
skuId
Guid
服务计划所在的 SKU SkuId。
响应
如果成功,此操作返回 204 No Content 响应代码。
示例
请求
POST https://graph.microsoft.com/beta/me/activateServicePlan
Content-type: application/json
{
"servicePlanId": "28f42d6f-8034-4a0f-9d8a-a218a63b3299",
"skuId": "465a2a90-5e59-456d-a7b8-127b9fb2e484"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var servicePlanId = Guid.Parse("28f42d6f-8034-4a0f-9d8a-a218a63b3299");
var skuId = Guid.Parse("465a2a90-5e59-456d-a7b8-127b9fb2e484");
await graphClient.Me
.ActivateServicePlan(servicePlanId,skuId)
.Request()
.PostAsync();
const options = {
authProvider,
};
const client = Client.init(options);
const activateServicePlan = {
servicePlanId: '28f42d6f-8034-4a0f-9d8a-a218a63b3299',
skuId: '465a2a90-5e59-456d-a7b8-127b9fb2e484'
};
await client.api('/me/activateServicePlan')
.version('beta')
.post(activateServicePlan);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/activateServicePlan"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
NSString *servicePlanId = @"28f42d6f-8034-4a0f-9d8a-a218a63b3299";
payloadDictionary[@"servicePlanId"] = servicePlanId;
NSString *skuId = @"465a2a90-5e59-456d-a7b8-127b9fb2e484";
payloadDictionary[@"skuId"] = skuId;
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();
UUID servicePlanId = UUID.fromString("28f42d6f-8034-4a0f-9d8a-a218a63b3299");
UUID skuId = UUID.fromString("465a2a90-5e59-456d-a7b8-127b9fb2e484");
graphClient.me()
.activateServicePlan(UserActivateServicePlanParameterSet
.newBuilder()
.withServicePlanId(servicePlanId)
.withSkuId(skuId)
.build())
.buildRequest()
.post();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.New()
servicePlanId := "28f42d6f-8034-4a0f-9d8a-a218a63b3299"
requestBody.SetServicePlanId(&servicePlanId)
skuId := "465a2a90-5e59-456d-a7b8-127b9fb2e484"
requestBody.SetSkuId(&skuId)
graphClient.Me().ActivateServicePlan().Post(requestBody)
Import-Module Microsoft.Graph.Users.Actions
$params = @{
ServicePlanId = "28f42d6f-8034-4a0f-9d8a-a218a63b3299"
SkuId = "465a2a90-5e59-456d-a7b8-127b9fb2e484"
}
# A UPN can also be used as -UserId.
Initialize-MgUserServicePlan -UserId $userId -BodyParameter $params
响应
HTTP/1.1 204 No Content