L’une des autorisations suivantes est nécessaire pour appeler cette API. Pour plus d’informations, notamment sur la façon de choisir les autorisations, voir Autorisations.
Type d’autorisation
Autorisations (de celle qui offre le plus de privilèges à celle qui en offre le moins)
Objectif d’installation défini par l’administrateur. Les valeurs possibles sont les suivantes : available, required, uninstall, availableWithoutEnrollment.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new MobileAppAssignment
{
OdataType = "#microsoft.graph.mobileAppAssignment",
Intent = InstallIntent.Required,
Target = new AllLicensedUsersAssignmentTarget
{
OdataType = "microsoft.graph.allLicensedUsersAssignmentTarget",
},
Settings = new WindowsUniversalAppXAppAssignmentSettings
{
OdataType = "microsoft.graph.windowsUniversalAppXAppAssignmentSettings",
UseDeviceContext = true,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.DeviceAppManagement.MobileApps["{mobileApp-id}"].Assignments["{mobileAppAssignment-id}"].PatchAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewMobileAppAssignment()
intent := graphmodels.REQUIRED_INSTALLINTENT
requestBody.SetIntent(&intent)
target := graphmodels.NewAllLicensedUsersAssignmentTarget()
requestBody.SetTarget(target)
settings := graphmodels.NewWindowsUniversalAppXAppAssignmentSettings()
useDeviceContext := true
settings.SetUseDeviceContext(&useDeviceContext)
requestBody.SetSettings(settings)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
assignments, err := graphClient.DeviceAppManagement().MobileApps().ByMobileAppId("mobileApp-id").Assignments().ByMobileAppAssignmentId("mobileAppAssignment-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
MobileAppAssignment mobileAppAssignment = new MobileAppAssignment();
mobileAppAssignment.setOdataType("#microsoft.graph.mobileAppAssignment");
mobileAppAssignment.setIntent(InstallIntent.Required);
AllLicensedUsersAssignmentTarget target = new AllLicensedUsersAssignmentTarget();
target.setOdataType("microsoft.graph.allLicensedUsersAssignmentTarget");
mobileAppAssignment.setTarget(target);
WindowsUniversalAppXAppAssignmentSettings settings = new WindowsUniversalAppXAppAssignmentSettings();
settings.setOdataType("microsoft.graph.windowsUniversalAppXAppAssignmentSettings");
settings.setUseDeviceContext(true);
mobileAppAssignment.setSettings(settings);
MobileAppAssignment result = graphClient.deviceAppManagement().mobileApps().byMobileAppId("{mobileApp-id}").assignments().byMobileAppAssignmentId("{mobileAppAssignment-id}").patch(mobileAppAssignment);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\MobileAppAssignment;
use Microsoft\Graph\Generated\Models\InstallIntent;
use Microsoft\Graph\Generated\Models\AllLicensedUsersAssignmentTarget;
use Microsoft\Graph\Generated\Models\WindowsUniversalAppXAppAssignmentSettings;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new MobileAppAssignment();
$requestBody->setOdataType('#microsoft.graph.mobileAppAssignment');
$requestBody->setIntent(new InstallIntent('required'));
$target = new AllLicensedUsersAssignmentTarget();
$target->setOdataType('microsoft.graph.allLicensedUsersAssignmentTarget');
$requestBody->setTarget($target);
$settings = new WindowsUniversalAppXAppAssignmentSettings();
$settings->setOdataType('microsoft.graph.windowsUniversalAppXAppAssignmentSettings');
$settings->setUseDeviceContext(true);
$requestBody->setSettings($settings);
$result = $graphServiceClient->deviceAppManagement()->mobileApps()->byMobileAppId('mobileApp-id')->assignments()->byMobileAppAssignmentId('mobileAppAssignment-id')->patch($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.mobile_app_assignment import MobileAppAssignment
from msgraph.generated.models.install_intent import InstallIntent
from msgraph.generated.models.all_licensed_users_assignment_target import AllLicensedUsersAssignmentTarget
from msgraph.generated.models.windows_universal_app_x_app_assignment_settings import WindowsUniversalAppXAppAssignmentSettings
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = MobileAppAssignment(
odata_type = "#microsoft.graph.mobileAppAssignment",
intent = InstallIntent.Required,
target = AllLicensedUsersAssignmentTarget(
odata_type = "microsoft.graph.allLicensedUsersAssignmentTarget",
),
settings = WindowsUniversalAppXAppAssignmentSettings(
odata_type = "microsoft.graph.windowsUniversalAppXAppAssignmentSettings",
use_device_context = True,
),
)
result = await graph_client.device_app_management.mobile_apps.by_mobile_app_id('mobileApp-id').assignments.by_mobile_app_assignment_id('mobileAppAssignment-id').patch(request_body)
Voici un exemple de réponse. Remarque : l’objet de réponse illustré ici peut être tronqué à des fins de concision. Toutes les propriétés sont renvoyées à partir d’un appel réel.