Kopieren Sie eine Datei an einen Standardinhaltsspeicherort in einem Inhaltstyp. Die Datei kann dann über einen POST-Vorgang als Standarddatei oder -vorlage hinzugefügt werden.
Wählen Sie für diese API die Als am wenigsten privilegierten Berechtigungen gekennzeichneten Berechtigungen aus. Verwenden Sie nur dann eine Berechtigung mit höheren Berechtigungen , wenn dies für Ihre App erforderlich ist. Ausführliche Informationen zu delegierten Berechtigungen und Anwendungsberechtigungen finden Sie unter Berechtigungstypen. Weitere Informationen zu diesen Berechtigungen finden Sie in der Berechtigungsreferenz.
Berechtigungstyp
Berechtigungen mit den geringsten Berechtigungen
Berechtigungen mit höheren Berechtigungen
Delegiert (Geschäfts-, Schul- oder Unikonto)
Sites.ReadWrite.All
Sites.FullControl.All, Sites.Manage.All
Delegiert (persönliches Microsoft-Konto)
Nicht unterstützt
Nicht unterstützt
Anwendung
Sites.ReadWrite.All
Sites.FullControl.All, Sites.Manage.All
HTTP-Anforderung
POST /sites/{siteId}/contentTypes/{contentTypeId}/copyToDefaultContentLocation
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Sites.Item.ContentTypes.Item.CopyToDefaultContentLocation;
using Microsoft.Graph.Models;
var requestBody = new CopyToDefaultContentLocationPostRequestBody
{
SourceFile = new ItemReference
{
SharepointIds = new SharepointIds
{
ListId = "e2ecf63b-b0fd-48f7-a54a-d8c15479e3b0",
ListItemId = "2",
},
},
DestinationFileName = "newname.txt",
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Sites["{site-id}"].ContentTypes["{contentType-id}"].CopyToDefaultContentLocation.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"
graphsites "github.com/microsoftgraph/msgraph-sdk-go/sites"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphsites.NewCopyToDefaultContentLocationPostRequestBody()
sourceFile := graphmodels.NewItemReference()
sharepointIds := graphmodels.NewSharepointIds()
listId := "e2ecf63b-b0fd-48f7-a54a-d8c15479e3b0"
sharepointIds.SetListId(&listId)
listItemId := "2"
sharepointIds.SetListItemId(&listItemId)
sourceFile.SetSharepointIds(sharepointIds)
requestBody.SetSourceFile(sourceFile)
destinationFileName := "newname.txt"
requestBody.SetDestinationFileName(&destinationFileName)
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Sites().BySiteId("site-id").ContentTypes().ByContentTypeId("contentType-id").CopyToDefaultContentLocation().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.sites.item.contenttypes.item.copytodefaultcontentlocation.CopyToDefaultContentLocationPostRequestBody copyToDefaultContentLocationPostRequestBody = new com.microsoft.graph.sites.item.contenttypes.item.copytodefaultcontentlocation.CopyToDefaultContentLocationPostRequestBody();
ItemReference sourceFile = new ItemReference();
SharepointIds sharepointIds = new SharepointIds();
sharepointIds.setListId("e2ecf63b-b0fd-48f7-a54a-d8c15479e3b0");
sharepointIds.setListItemId("2");
sourceFile.setSharepointIds(sharepointIds);
copyToDefaultContentLocationPostRequestBody.setSourceFile(sourceFile);
copyToDefaultContentLocationPostRequestBody.setDestinationFileName("newname.txt");
graphClient.sites().bySiteId("{site-id}").contentTypes().byContentTypeId("{contentType-id}").copyToDefaultContentLocation().post(copyToDefaultContentLocationPostRequestBody);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Sites\Item\ContentTypes\Item\CopyToDefaultContentLocation\CopyToDefaultContentLocationPostRequestBody;
use Microsoft\Graph\Generated\Models\ItemReference;
use Microsoft\Graph\Generated\Models\SharepointIds;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new CopyToDefaultContentLocationPostRequestBody();
$sourceFile = new ItemReference();
$sourceFileSharepointIds = new SharepointIds();
$sourceFileSharepointIds->setListId('e2ecf63b-b0fd-48f7-a54a-d8c15479e3b0');
$sourceFileSharepointIds->setListItemId('2');
$sourceFile->setSharepointIds($sourceFileSharepointIds);
$requestBody->setSourceFile($sourceFile);
$requestBody->setDestinationFileName('newname.txt');
$graphServiceClient->sites()->bySiteId('site-id')->contentTypes()->byContentTypeId('contentType-id')->copyToDefaultContentLocation()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.sites.item.contenttypes.item.copy_to_default_content_location.copy_to_default_content_location_post_request_body import CopyToDefaultContentLocationPostRequestBody
from msgraph.generated.models.item_reference import ItemReference
from msgraph.generated.models.sharepoint_ids import SharepointIds
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = CopyToDefaultContentLocationPostRequestBody(
source_file = ItemReference(
sharepoint_ids = SharepointIds(
list_id = "e2ecf63b-b0fd-48f7-a54a-d8c15479e3b0",
list_item_id = "2",
),
),
destination_file_name = "newname.txt",
)
await graph_client.sites.by_site_id('site-id').content_types.by_content_type_id('contentType-id').copy_to_default_content_location.post(request_body)