Namespace: microsoft.graph
Note: The Microsoft Graph API for Intune requires an active Intune license for the tenant.
Update the properties of a mobileAppAssignment object.
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
✅ |
✅ |
✅ |
Permissions
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) |
DeviceManagementApps.ReadWrite.All |
Delegated (personal Microsoft account) |
Not supported. |
Application |
DeviceManagementApps.ReadWrite.All |
HTTP Request
PATCH /deviceAppManagement/mobileApps/{mobileAppId}/assignments/{mobileAppAssignmentId}
Request body
In the request body, supply a JSON representation for the mobileAppAssignment object.
The following table shows the properties that are required when you create the mobileAppAssignment.
Response
If successful, this method returns a 200 OK
response code and an updated mobileAppAssignment object in the response body.
Example
Request
Here is an example of the request.
PATCH https://graph.microsoft.com/v1.0/deviceAppManagement/mobileApps/{mobileAppId}/assignments/{mobileAppAssignmentId}
Content-type: application/json
Content-length: 312
{
"@odata.type": "#microsoft.graph.mobileAppAssignment",
"intent": "required",
"target": {
"@odata.type": "microsoft.graph.allLicensedUsersAssignmentTarget"
},
"settings": {
"@odata.type": "microsoft.graph.windowsUniversalAppXAppAssignmentSettings",
"useDeviceContext": true
}
}
// 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);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
mgc device-app-management mobile-apps assignments patch --mobile-app-id {mobileApp-id} --mobile-app-assignment-id {mobileAppAssignment-id} --body '{\
"@odata.type": "#microsoft.graph.mobileAppAssignment",\
"intent": "required",\
"target": {\
"@odata.type": "microsoft.graph.allLicensedUsersAssignmentTarget"\
},\
"settings": {\
"@odata.type": "microsoft.graph.windowsUniversalAppXAppAssignmentSettings",\
"useDeviceContext": true\
}\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// 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)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// 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);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const mobileAppAssignment = {
'@odata.type': '#microsoft.graph.mobileAppAssignment',
intent: 'required',
target: {
'@odata.type': 'microsoft.graph.allLicensedUsersAssignmentTarget'
},
settings: {
'@odata.type': 'microsoft.graph.windowsUniversalAppXAppAssignmentSettings',
useDeviceContext: true
}
};
await client.api('/deviceAppManagement/mobileApps/{mobileAppId}/assignments/{mobileAppAssignmentId}')
.update(mobileAppAssignment);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?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();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Devices.CorporateManagement
$params = @{
"@odata.type" = "#microsoft.graph.mobileAppAssignment"
intent = "required"
target = @{
"@odata.type" = "microsoft.graph.allLicensedUsersAssignmentTarget"
}
settings = @{
"@odata.type" = "microsoft.graph.windowsUniversalAppXAppAssignmentSettings"
useDeviceContext = $true
}
}
Update-MgDeviceAppManagementMobileAppAssignment -MobileAppId $mobileAppId -MobileAppAssignmentId $mobileAppAssignmentId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# 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)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
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: 361
{
"@odata.type": "#microsoft.graph.mobileAppAssignment",
"id": "591620b7-20b7-5916-b720-1659b7201659",
"intent": "required",
"target": {
"@odata.type": "microsoft.graph.allLicensedUsersAssignmentTarget"
},
"settings": {
"@odata.type": "microsoft.graph.windowsUniversalAppXAppAssignmentSettings",
"useDeviceContext": true
}
}