Espace de noms: microsoft.graph
Importante
Les API sous la version /beta dans Microsoft Graph sont susceptibles d’être modifiées. L’utilisation de ces API dans des applications de production n’est pas prise en charge. Pour déterminer si une API est disponible dans v1.0, utilisez le sélecteur Version .
Archive un élément de lecteur.
Lors de l’archivage d’un seul fichier actif à l’aide d’une requête synchrone, le fichier est archivé immédiatement.
Remarque
L’archivage d’un fichier driveItem n’est pas pris en charge lorsque la demande inclut l’en-tête Prefer :respond-async.
Lors de l’archivage d’un dossier à l’aide d’une requête asynchrone, une URL de moniteur est renvoyée dans la réponse. Utilisez l’URL du moniteur pour suivre la progression jusqu’à la fin de l’opération.
Remarque
L’archivage d’un dossier driveItem n’est pris en charge que lorsque la demande inclut l’en-tête Prefer :respond-async
Cette API est disponible dans les déploiements cloud nationaux suivants.
| Service global |
Gouvernement américain L4 |
Gouvernement américain L5 (DOD) |
Chine exploitée par 21Vianet |
| ✅ |
✅ |
✅ |
✅ |
Autorisations
Choisissez l’autorisation ou les autorisations marquées comme étant les moins privilégiées pour cette API. Utilisez une ou plusieurs autorisations privilégiées uniquement si votre application en a besoin. Pour plus d’informations sur les autorisations déléguées et d’application, voir Types d’autorisations. Pour en savoir plus sur ces autorisations, consultez la référence des autorisations.
| Type d’autorisation |
Autorisations les moins privilégiées |
Autorisations à privilèges plus élevés |
| Déléguée (compte professionnel ou scolaire) |
Files.ReadWrite |
Files. ReadWrite.All, Sites.FullControl.All, Sites.Manage.All, Sites.ReadWrite.All |
| Déléguée (compte Microsoft personnel) |
Non prise en charge. |
Non prise en charge. |
| Application |
Files.ReadWrite.All |
Sites.FullControl.All, Sites.Manage.All, Sites.ReadWrite.All |
Requête HTTP
POST /drive/root/archive
POST /drives/{drivesId}/root/archive
POST /shares/{sharesId}/root/archive
POST /drives/{drivesId}/items/{driveItemId}/archive
POST /drive/items/{driveItemId}/archive
POST /shares/{sharesId}/driveItem/archive
POST /drive/bundles/{driveItemId}/archive
POST /drive/special/{driveItemId}/archive
POST /drive/following/{driveItemId}/archive
| Nom |
Description |
| Autorisation |
Porteur {token}. Obligatoire. En savoir plus sur l’authentification et les autorisations. |
| Préférence |
respond-async. Indique que la demande est une demande asynchrone. Facultatif. |
Corps de la demande
N’indiquez pas le corps de la demande pour cette méthode.
Réponse
En cas de réussite, cette action renvoie un 204 No Content code de réponse pour un fichier driveItem .
Dans le cas contraire, en cas de succès, cette action renvoie un 202 Accepted code de réponse avec un URI de moniteur pour un dossier driveItem .
Exemples
Exemple 1 : Fichier driveItem d’Archive
Demande
L’exemple suivant illustre une demande.
POST https://graph.microsoft.com/beta/drives/b!fMInbiL5dkK51VbATG0ddrCg6AJpEj9Lm4uGj5HgEi4guyuYp4W5SbH4dPfXTbCF/items/014Y52UITTNSVUQI43PZBJMKLAY6LJBUVE/archive
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].Archive.PostAsync();
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Drives().ByDriveId("drive-id").Items().ByDriveItemId("driveItem-id").Archive().Post(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.drives().byDriveId("{drive-id}").items().byDriveItemId("{driveItem-id}").archive().post();
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/drives/b!fMInbiL5dkK51VbATG0ddrCg6AJpEj9Lm4uGj5HgEi4guyuYp4W5SbH4dPfXTbCF/items/014Y52UITTNSVUQI43PZBJMKLAY6LJBUVE/archive')
.version('beta')
.post();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$graphServiceClient->drives()->byDriveId('drive-id')->items()->byDriveItemId('driveItem-id')->archive()->post()->wait();
Import-Module Microsoft.Graph.Beta.Files
Invoke-MgBetaArchiveDriveItem -DriveId $driveId -DriveItemId $driveItemId
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
await graph_client.drives.by_drive_id('drive-id').items.by_drive_item_id('driveItem-id').archive.post()
Réponse
L’exemple suivant illustre la réponse.
Remarque : l’objet de réponse affiché ci-après peut être raccourci pour plus de lisibilité.
HTTP/1.1 204 No Content
Exemple 2 : dossier driveItem d’Archive
Demande
L’exemple suivant illustre une demande.
POST https://graph.microsoft.com/beta/drives/b!fMInbiL5dkK51VbATG0ddrCg6AJpEj9Lm4uGj5HgEi4guyuYp4W5SbH4dPfXTbCF/items/014Y52UITTNSVUQI43PZBJMKLAY6LJBUVE/archive
Prefer: respond-async
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].Archive.PostAsync((requestConfiguration) =>
{
requestConfiguration.Headers.Add("Prefer", "respond-async");
});
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphdrives "github.com/microsoftgraph/msgraph-beta-sdk-go/drives"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("Prefer", "respond-async")
configuration := &graphdrives.ItemItemsItemArchiveRequestBuilderPostRequestConfiguration{
Headers: headers,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Drives().ByDriveId("drive-id").Items().ByDriveItemId("driveItem-id").Archive().Post(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.drives().byDriveId("{drive-id}").items().byDriveItemId("{driveItem-id}").archive().post(requestConfiguration -> {
requestConfiguration.headers.add("Prefer", "respond-async");
});
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/drives/b!fMInbiL5dkK51VbATG0ddrCg6AJpEj9Lm4uGj5HgEi4guyuYp4W5SbH4dPfXTbCF/items/014Y52UITTNSVUQI43PZBJMKLAY6LJBUVE/archive')
.version('beta')
.post();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Drives\Item\Items\Item\Archive\ArchiveRequestBuilderPostRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new ArchiveRequestBuilderPostRequestConfiguration();
$headers = [
'Prefer' => 'respond-async',
];
$requestConfiguration->headers = $headers;
$graphServiceClient->drives()->byDriveId('drive-id')->items()->byDriveItemId('driveItem-id')->archive()->post($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Files
Invoke-MgBetaArchiveDriveItem -DriveId $driveId -DriveItemId $driveItemId
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.drives.item.items.item.archive.archive_request_builder import ArchiveRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_configuration = RequestConfiguration()
request_configuration.headers.add("Prefer", "respond-async")
await graph_client.drives.by_drive_id('drive-id').items.by_drive_item_id('driveItem-id').archive.post(request_configuration = request_configuration)
Réponse
L’exemple suivant illustre la réponse.
Remarque : l’objet de réponse affiché ci-après peut être raccourci pour plus de lisibilité.
HTTP/1.1 202 Accepted
Location: https://graph.microsoft.com/monitor/4A3407B5-88FC-4504-8B21-0AABD3412717