contentType: copyToDefaultContentLocation
Artikel
07/18/2022
2 Minuten Lesedauer
3 Mitwirkende
In diesem Artikel
Namespace: microsoft.graph
Kopieren Sie eine Datei an einen Standardinhaltsspeicherort in einem Inhaltstyp . Die Datei kann dann als Standarddatei oder Vorlage über einen POST-Vorgang hinzugefügt werden.
Berechtigungen
Eine der nachfolgenden Berechtigungen ist erforderlich, um diese API aufrufen zu können. Weitere Informationen, unter anderem zur Auswahl von Berechtigungen, finden Sie im Artikel zum Thema Berechtigungen .
Berechtigungstyp
Berechtigungen (von der Berechtigung mit den wenigsten Rechten zu der mit den meisten Rechten)
Delegiert (Geschäfts-, Schul- oder Unikonto)
Sites.ReadWrite.All, Sites.Manage.All, Sites.FullControl.All
Delegiert (persönliches Microsoft-Konto)
Nicht unterstützt
Anwendung
Sites.ReadWrite.All, Sites.Manage.All, Sites.FullControl.All
HTTP-Anforderung
POST /sites/{siteId}/contentTypes/{contentTypeId}/copyToDefaultContentLocation
Name
Beschreibung
Authorization
Bearer {token}. Erforderlich.
Content-Type
application/json. Erforderlich.
Anforderungstext
Geben Sie im Anforderungstext eine JSON-Darstellung der Parameter an.
In der folgenden Tabelle sind die Parameter aufgeführt, die mit dieser Aktion verwendet werden können.
Parameter
Typ
Beschreibung
Sourcefile
itemReference
Metadaten zu der Quelldatei, die an den Standardinhaltsspeicherort kopiert werden muss. Erforderlich.
Destinationfilename
string
Zieldateiname.
Antwort
Bei erfolgreicher Ausführung gibt dieser Aufruf eine 204 No Content Antwort zurück.
Beispiel
Anforderung
POST https://graph.microsoft.com/v1.0/sites/{siteId}/contentTypes/{contentTypeId}/copyToDefaultContentLocation
Content-Type: application/json
{
"sourceFile":{
"sharepointIds":{
"listId":"e2ecf63b-b0fd-48f7-a54a-d8c15479e3b0",
"listItemId":"2"
}
},
"destinationFileName":"newname.txt"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var sourceFile = new ItemReference
{
SharepointIds = new SharepointIds
{
ListId = "e2ecf63b-b0fd-48f7-a54a-d8c15479e3b0",
ListItemId = "2"
}
};
var destinationFileName = "newname.txt";
await graphClient.Sites["{site-id}"].ContentTypes["{contentType-id}"]
.CopyToDefaultContentLocation(sourceFile,destinationFileName)
.Request()
.PostAsync();
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
const options = {
authProvider,
};
const client = Client.init(options);
const copyToDefaultContentLocation = {
sourceFile: {
sharepointIds: {
listId: 'e2ecf63b-b0fd-48f7-a54a-d8c15479e3b0',
listItemId: '2'
}
},
destinationFileName: 'newname.txt'
};
await client.api('/sites/{siteId}/contentTypes/{contentTypeId}/copyToDefaultContentLocation')
.post(copyToDefaultContentLocation);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/sites/{siteId}/contentTypes/{contentTypeId}/copyToDefaultContentLocation"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
MSGraphItemReference *sourceFile = [[MSGraphItemReference alloc] init];
MSGraphSharepointIds *sharepointIds = [[MSGraphSharepointIds alloc] init];
[sharepointIds setListId:@"e2ecf63b-b0fd-48f7-a54a-d8c15479e3b0"];
[sharepointIds setListItemId:@"2"];
[sourceFile setSharepointIds:sharepointIds];
payloadDictionary[@"sourceFile"] = sourceFile;
NSString *destinationFileName = @"newname.txt";
payloadDictionary[@"destinationFileName"] = destinationFileName;
NSData *data = [NSJSONSerialization dataWithJSONObject:payloadDictionary options:kNilOptions error:&error];
[urlRequest setHTTPBody:data];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
ItemReference sourceFile = new ItemReference();
SharepointIds sharepointIds = new SharepointIds();
sharepointIds.listId = "e2ecf63b-b0fd-48f7-a54a-d8c15479e3b0";
sharepointIds.listItemId = "2";
sourceFile.sharepointIds = sharepointIds;
String destinationFileName = "newname.txt";
graphClient.sites("{siteId}").contentTypes("{contentTypeId}")
.copyToDefaultContentLocation(ContentTypeCopyToDefaultContentLocationParameterSet
.newBuilder()
.withSourceFile(sourceFile)
.withDestinationFileName(destinationFileName)
.build())
.buildRequest()
.post();
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.New()
sourceFile := msgraphsdk.NewItemReference()
requestBody.SetSourceFile(sourceFile)
sharepointIds := msgraphsdk.NewSharepointIds()
sourceFile.SetSharepointIds(sharepointIds)
listId := "e2ecf63b-b0fd-48f7-a54a-d8c15479e3b0"
sharepointIds.SetListId(&listId)
listItemId := "2"
sharepointIds.SetListItemId(&listItemId)
destinationFileName := "newname.txt"
requestBody.SetDestinationFileName(&destinationFileName)
siteId := "site-id"
contentTypeId := "contentType-id"
graphClient.SitesById(&siteId).ContentTypesById(&contentTypeId).CopyToDefaultContentLocation(site-id, contentType-id).Post(requestBody)
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
Import-Module Microsoft.Graph.Sites
$params = @{
SourceFile = @{
SharepointIds = @{
ListId = "e2ecf63b-b0fd-48f7-a54a-d8c15479e3b0"
ListItemId = "2"
}
}
DestinationFileName = "newname.txt"
}
Copy-MgSiteContentTypeToDefaultContentLocation -SiteId $siteId -ContentTypeId $contentTypeId -BodyParameter $params
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
Antwort
HTTP/1.1 204 No Content