// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.DeviceAppManagement.ManagedEBooks.Item.Assign;
using Microsoft.Graph.Models;
var requestBody = new AssignPostRequestBody
{
ManagedEBookAssignments = new List<ManagedEBookAssignment>
{
new ManagedEBookAssignment
{
OdataType = "#microsoft.graph.managedEBookAssignment",
Id = "ae8b0d27-0d27-ae8b-270d-8bae270d8bae",
Target = new AllLicensedUsersAssignmentTarget
{
OdataType = "microsoft.graph.allLicensedUsersAssignmentTarget",
},
InstallIntent = InstallIntent.Required,
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.DeviceAppManagement.ManagedEBooks["{managedEBook-id}"].Assign.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.NewAssignPostRequestBody()
managedEBookAssignment := graphmodels.NewManagedEBookAssignment()
id := "ae8b0d27-0d27-ae8b-270d-8bae270d8bae"
managedEBookAssignment.SetId(&id)
target := graphmodels.NewAllLicensedUsersAssignmentTarget()
managedEBookAssignment.SetTarget(target)
installIntent := graphmodels.REQUIRED_INSTALLINTENT
managedEBookAssignment.SetInstallIntent(&installIntent)
managedEBookAssignments := []graphmodels.ManagedEBookAssignmentable {
managedEBookAssignment,
}
requestBody.SetManagedEBookAssignments(managedEBookAssignments)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.DeviceAppManagement().ManagedEBooks().ByManagedEBookId("managedEBook-id").Assign().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.managedebooks.item.assign.AssignPostRequestBody assignPostRequestBody = new com.microsoft.graph.deviceappmanagement.managedebooks.item.assign.AssignPostRequestBody();
LinkedList<ManagedEBookAssignment> managedEBookAssignments = new LinkedList<ManagedEBookAssignment>();
ManagedEBookAssignment managedEBookAssignment = new ManagedEBookAssignment();
managedEBookAssignment.setOdataType("#microsoft.graph.managedEBookAssignment");
managedEBookAssignment.setId("ae8b0d27-0d27-ae8b-270d-8bae270d8bae");
AllLicensedUsersAssignmentTarget target = new AllLicensedUsersAssignmentTarget();
target.setOdataType("microsoft.graph.allLicensedUsersAssignmentTarget");
managedEBookAssignment.setTarget(target);
managedEBookAssignment.setInstallIntent(InstallIntent.Required);
managedEBookAssignments.add(managedEBookAssignment);
assignPostRequestBody.setManagedEBookAssignments(managedEBookAssignments);
graphClient.deviceAppManagement().managedEBooks().byManagedEBookId("{managedEBook-id}").assign().post(assignPostRequestBody);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\DeviceAppManagement\ManagedEBooks\Item\Assign\AssignPostRequestBody;
use Microsoft\Graph\Generated\Models\ManagedEBookAssignment;
use Microsoft\Graph\Generated\Models\AllLicensedUsersAssignmentTarget;
use Microsoft\Graph\Generated\Models\InstallIntent;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AssignPostRequestBody();
$managedEBookAssignmentsManagedEBookAssignment1 = new ManagedEBookAssignment();
$managedEBookAssignmentsManagedEBookAssignment1->setOdataType('#microsoft.graph.managedEBookAssignment');
$managedEBookAssignmentsManagedEBookAssignment1->setId('ae8b0d27-0d27-ae8b-270d-8bae270d8bae');
$managedEBookAssignmentsManagedEBookAssignment1Target = new AllLicensedUsersAssignmentTarget();
$managedEBookAssignmentsManagedEBookAssignment1Target->setOdataType('microsoft.graph.allLicensedUsersAssignmentTarget');
$managedEBookAssignmentsManagedEBookAssignment1->setTarget($managedEBookAssignmentsManagedEBookAssignment1Target);
$managedEBookAssignmentsManagedEBookAssignment1->setInstallIntent(new InstallIntent('required'));
$managedEBookAssignmentsArray []= $managedEBookAssignmentsManagedEBookAssignment1;
$requestBody->setManagedEBookAssignments($managedEBookAssignmentsArray);
$graphServiceClient->deviceAppManagement()->managedEBooks()->byManagedEBookId('managedEBook-id')->assign()->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.managedebooks.item.assign.assign_post_request_body import AssignPostRequestBody
from msgraph.generated.models.managed_e_book_assignment import ManagedEBookAssignment
from msgraph.generated.models.all_licensed_users_assignment_target import AllLicensedUsersAssignmentTarget
from msgraph.generated.models.install_intent import InstallIntent
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AssignPostRequestBody(
managed_e_book_assignments = [
ManagedEBookAssignment(
odata_type = "#microsoft.graph.managedEBookAssignment",
id = "ae8b0d27-0d27-ae8b-270d-8bae270d8bae",
target = AllLicensedUsersAssignmentTarget(
odata_type = "microsoft.graph.allLicensedUsersAssignmentTarget",
),
install_intent = InstallIntent.Required,
),
],
)
await graph_client.device_app_management.managed_e_books.by_managed_e_book_id('managedEBook-id').assign.post(request_body)
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.