user: assignLicense user: assignLicense
この記事の内容
名前空間: microsoft.graph ユーザーのサブスクリプションを追加または削除します。サブスクリプションに関連付けられている特定のプランを有効または無効にすることもできます。 Namespace: microsoft.graph Add or remove subscriptions for the user. You can also enable and disable specific plans associated with a subscription.
アクセス許可 Permissions
この API を呼び出すには、次のいずれかのアクセス許可が必要です。アクセス許可の選択方法などの詳細については、「アクセス許可 」を参照してください。 One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions .
アクセス許可の種類 Permission type
アクセス許可 (特権の小さいものから大きいものへ) Permissions (from least to most privileged)
委任 (職場または学校のアカウント) Delegated (work or school account)
User.ReadWrite.All、Directory.ReadWrite.All User.ReadWrite.All, Directory.ReadWrite.All
委任 (個人用 Microsoft アカウント) Delegated (personal Microsoft account)
サポートされていません。 Not supported.
アプリケーション Application
User.ReadWrite.All、Directory.ReadWrite.All User.ReadWrite.All, Directory.ReadWrite.All
HTTP 要求 HTTP request
POST /users/{id | userPrincipalName}/assignLicense
ヘッダー Header
値 Value
Authorization Authorization
ベアラー {トークン}。必須。 Bearer {token}. Required.
Content-Type Content-Type
application/json application/json
要求本文 Request body
要求本文で、次のパラメーターを含む JSON オブジェクトを指定します。 In the request body, provide a JSON object with the following parameters.
パラメーター Parameter
種類 Type
説明 Description
addLicenses addLicenses
AssignedLicense collection AssignedLicense collection
追加するライセンスを指定する assignedLicense オブジェクトのコレクションです。assignedLicense オブジェクト上で disabledPlans プロパティを設定すると、ライセンスに関連付けられたプランを無効にできます。 A collection of assignedLicense objects that specify the licenses to add. You can disable plans associated with a license by setting the disabledPlans property on an assignedLicense object.
removeLicenses removeLicenses
Guid コレクション Guid collection
削除するライセンスを識別する GUID のコレクションです。 A collection of GUIDs that identify the licenses to remove.
応答 Response
成功した場合、このメソッドは 200 OK
応答コードと、応答本文でユーザー オブジェクトを返します。 If successful, this method returns 200 OK
response code and user object in the response body.
例 Example
以下は、この API を呼び出す方法の例です。 Here is an example of how to call this API.
要求 Request
以下は、要求の例です。 Here is an example of the request.
POST https://graph.microsoft.com/v1.0/me/assignLicense
Content-type: application/json
Content-length: 185
{
"addLicenses": [
{
"disabledPlans": [ "11b0131d-43c8-4bbb-b2c8-e80f9a50834a" ],
"skuId": "guid"
}
],
"removeLicenses": [ "bea13e0c-3828-4daa-a392-28af7ff61a0f" ]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var addLicenses = new List<AssignedLicense>()
{
new AssignedLicense
{
DisabledPlans = new List<Guid>()
{
Guid.Parse("11b0131d-43c8-4bbb-b2c8-e80f9a50834a")
},
SkuId = Guid.Parse("guid")
}
};
var removeLicenses = new List<Guid>()
{
Guid.Parse("bea13e0c-3828-4daa-a392-28af7ff61a0f")
};
await graphClient.Me
.AssignLicense(addLicenses,removeLicenses)
.Request()
.PostAsync();
SDK をプロジェクトに追加 し、 authprovider インスタンスを作成する方法の詳細については、 sdk のドキュメント を参照してください。 Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
const options = {
authProvider,
};
const client = Client.init(options);
const user = {
addLicenses: [
{
disabledPlans: [ "11b0131d-43c8-4bbb-b2c8-e80f9a50834a" ],
skuId: "guid"
}
],
removeLicenses: [ "bea13e0c-3828-4daa-a392-28af7ff61a0f" ]
};
let res = await client.api('/me/assignLicense')
.post(user);
SDK をプロジェクトに追加 し、 authprovider インスタンスを作成する方法の詳細については、 sdk のドキュメント を参照してください。 Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/assignLicense"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
NSMutableArray *addLicensesList = [[NSMutableArray alloc] init];
MSGraphAssignedLicense *addLicenses = [[MSGraphAssignedLicense alloc] init];
NSMutableArray *disabledPlansList = [[NSMutableArray alloc] init];
[disabledPlansList addObject: @"11b0131d-43c8-4bbb-b2c8-e80f9a50834a"];
[addLicenses setDisabledPlans:disabledPlansList];
[addLicenses setSkuId:@"guid"];
[addLicensesList addObject: addLicenses];
payloadDictionary[@"addLicenses"] = addLicensesList;
NSMutableArray *removeLicensesList = [[NSMutableArray alloc] init];
[removeLicensesList addObject: @"bea13e0c-3828-4daa-a392-28af7ff61a0f"];
payloadDictionary[@"removeLicenses"] = removeLicensesList;
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];
SDK をプロジェクトに追加 し、 authprovider インスタンスを作成する方法の詳細については、 sdk のドキュメント を参照してください。 Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
IGraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<AssignedLicense> addLicensesList = new LinkedList<AssignedLicense>();
AssignedLicense addLicenses = new AssignedLicense();
LinkedList<UUID> disabledPlansList = new LinkedList<UUID>();
disabledPlansList.add(UUID.fromString("11b0131d-43c8-4bbb-b2c8-e80f9a50834a"));
addLicenses.disabledPlans = disabledPlansList;
addLicenses.skuId = UUID.fromString("guid");
addLicensesList.add(addLicenses);
LinkedList<UUID> removeLicensesList = new LinkedList<UUID>();
removeLicensesList.add(UUID.fromString("bea13e0c-3828-4daa-a392-28af7ff61a0f"));
graphClient.me()
.assignLicense(addLicensesList,removeLicensesList)
.buildRequest()
.post();
SDK をプロジェクトに追加 し、 authprovider インスタンスを作成する方法の詳細については、 sdk のドキュメント を参照してください。 Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
応答 Response
以下は、応答の例です。注:簡潔にするために、ここに示す応答オブジェクトは切り詰められている場合があります。すべてのプロパティは実際の呼び出しから返されます。 Here is an example of the response. Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.
HTTP/1.1 200 OK
Content-type: application/json
Content-length: 491
{
"accountEnabled": true,
"assignedLicenses": [
{
"disabledPlans": [ "11b0131d-43c8-4bbb-b2c8-e80f9a50834a" ],
"skuId": "0118A350-71FC-4EC3-8F0C-6A1CB8867561"
}
],
"assignedPlans": [
{
"assignedDateTime": "2016-10-02T12:13:14Z",
"capabilityStatus": "capabilityStatus-value",
"service": "service-value",
"servicePlanId": "bea13e0c-3828-4daa-a392-28af7ff61a0f"
}
],
"businessPhones": [
"businessPhones-value"
],
"city": "city-value",
"companyName": "companyName-value"
}