Se requiere uno de los siguientes permisos para llamar a esta API. Para obtener más información, incluido cómo elegir permisos, vea Permisos.
Tipo de permiso
Permisos (de menos a más privilegiados)
Delegado (cuenta profesional o educativa)
DeviceManagementApps.ReadWrite.All
Delegado (cuenta personal de Microsoft)
No admitida.
Aplicación
DeviceManagementApps.ReadWrite.All
Solicitud HTTP
POST /deviceAppManagement/managedAppPolicies/{managedAppPolicyId}/targetApps
POST /deviceAppManagement/managedAppRegistrations/{managedAppRegistrationId}/appliedPolicies/{managedAppPolicyId}/targetApps
POST /deviceAppManagement/managedAppRegistrations/{managedAppRegistrationId}/intendedPolicies/{managedAppPolicyId}/targetApps
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.DeviceAppManagement.ManagedAppPolicies.Item.TargetApps;
using Microsoft.Graph.Models;
var requestBody = new TargetAppsPostRequestBody
{
Apps = new List<ManagedMobileApp>
{
new ManagedMobileApp
{
OdataType = "#microsoft.graph.managedMobileApp",
MobileAppIdentifier = new AndroidMobileAppIdentifier
{
OdataType = "microsoft.graph.androidMobileAppIdentifier",
PackageId = "Package Id value",
},
Id = "0a129715-9715-0a12-1597-120a1597120a",
Version = "Version value",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.DeviceAppManagement.ManagedAppPolicies["{managedAppPolicy-id}"].TargetApps.PostAsync(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"
graphdeviceappmanagement "github.com/microsoftgraph/msgraph-sdk-go/deviceappmanagement"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphdeviceappmanagement.NewTargetAppsPostRequestBody()
managedMobileApp := graphmodels.NewManagedMobileApp()
mobileAppIdentifier := graphmodels.NewAndroidMobileAppIdentifier()
packageId := "Package Id value"
mobileAppIdentifier.SetPackageId(&packageId)
managedMobileApp.SetMobileAppIdentifier(mobileAppIdentifier)
id := "0a129715-9715-0a12-1597-120a1597120a"
managedMobileApp.SetId(&id)
version := "Version value"
managedMobileApp.SetVersion(&version)
apps := []graphmodels.ManagedMobileAppable {
managedMobileApp,
}
requestBody.SetApps(apps)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.DeviceAppManagement().ManagedAppPolicies().ByManagedAppPolicyId("managedAppPolicy-id").TargetApps().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.deviceappmanagement.managedapppolicies.item.targetapps.TargetAppsPostRequestBody targetAppsPostRequestBody = new com.microsoft.graph.deviceappmanagement.managedapppolicies.item.targetapps.TargetAppsPostRequestBody();
LinkedList<ManagedMobileApp> apps = new LinkedList<ManagedMobileApp>();
ManagedMobileApp managedMobileApp = new ManagedMobileApp();
managedMobileApp.setOdataType("#microsoft.graph.managedMobileApp");
AndroidMobileAppIdentifier mobileAppIdentifier = new AndroidMobileAppIdentifier();
mobileAppIdentifier.setOdataType("microsoft.graph.androidMobileAppIdentifier");
mobileAppIdentifier.setPackageId("Package Id value");
managedMobileApp.setMobileAppIdentifier(mobileAppIdentifier);
managedMobileApp.setId("0a129715-9715-0a12-1597-120a1597120a");
managedMobileApp.setVersion("Version value");
apps.add(managedMobileApp);
targetAppsPostRequestBody.setApps(apps);
graphClient.deviceAppManagement().managedAppPolicies().byManagedAppPolicyId("{managedAppPolicy-id}").targetApps().post(targetAppsPostRequestBody);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\DeviceAppManagement\ManagedAppPolicies\Item\TargetApps\TargetAppsPostRequestBody;
use Microsoft\Graph\Generated\Models\ManagedMobileApp;
use Microsoft\Graph\Generated\Models\AndroidMobileAppIdentifier;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new TargetAppsPostRequestBody();
$appsManagedMobileApp1 = new ManagedMobileApp();
$appsManagedMobileApp1->setOdataType('#microsoft.graph.managedMobileApp');
$appsManagedMobileApp1MobileAppIdentifier = new AndroidMobileAppIdentifier();
$appsManagedMobileApp1MobileAppIdentifier->setOdataType('microsoft.graph.androidMobileAppIdentifier');
$appsManagedMobileApp1MobileAppIdentifier->setPackageId('Package Id value');
$appsManagedMobileApp1->setMobileAppIdentifier($appsManagedMobileApp1MobileAppIdentifier);
$appsManagedMobileApp1->setId('0a129715-9715-0a12-1597-120a1597120a');
$appsManagedMobileApp1->setVersion('Version value');
$appsArray []= $appsManagedMobileApp1;
$requestBody->setApps($appsArray);
$graphServiceClient->deviceAppManagement()->managedAppPolicies()->byManagedAppPolicyId('managedAppPolicy-id')->targetApps()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.deviceappmanagement.managedapppolicies.item.target_apps.target_apps_post_request_body import TargetAppsPostRequestBody
from msgraph.generated.models.managed_mobile_app import ManagedMobileApp
from msgraph.generated.models.android_mobile_app_identifier import AndroidMobileAppIdentifier
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = TargetAppsPostRequestBody(
apps = [
ManagedMobileApp(
odata_type = "#microsoft.graph.managedMobileApp",
mobile_app_identifier = AndroidMobileAppIdentifier(
odata_type = "microsoft.graph.androidMobileAppIdentifier",
package_id = "Package Id value",
),
id = "0a129715-9715-0a12-1597-120a1597120a",
version = "Version value",
),
],
)
await graph_client.device_app_management.managed_app_policies.by_managed_app_policy_id('managedAppPolicy-id').target_apps.post(request_body)
Aquí tiene un ejemplo de la respuesta. Nota: Es posible que el objeto de respuesta que aparezca aquí esté truncado para abreviar. Todas las propiedades se devolverán desde una llamada real.