contentType: copyToDefaultContentLocation
-
[アーティクル]
-
-
名前空間: microsoft.graph
ファイルをコンテンツ タイプの既定のコンテンツの場所に コピーします。 その後、POST 操作を使用して既定のファイルまたはテンプレートとしてファイルを追加できます。
アクセス許可
この API を呼び出すには、次のいずれかのアクセス許可が必要です。アクセス許可の選択方法などの詳細については、「アクセス許可」を参照してください。
| アクセス許可の種類 |
アクセス許可 (特権の小さいものから大きいものへ) |
| 委任 (職場または学校のアカウント) |
Sites.ReadWrite.All、Sites.Manage.All、Sites.FullControl.All |
| 委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
| Application |
Sites.ReadWrite.All、Sites.Manage.All、Sites.FullControl.All |
HTTP 要求
POST /sites/{siteId}/contentTypes/{contentTypeId}/copyToDefaultContentLocation
| 名前 |
説明 |
| Authorization |
ベアラー {token}。必須。 |
| Content-Type |
application/json. Required. |
要求本文
要求本文で、パラメーターの JSON 表記を指定します。
次の表に、このアクションで使用できるパラメーターを示します。
| パラメーター |
種類 |
説明 |
| sourceFile |
itemReference |
既定のコンテンツの場所にコピーする必要があるソース ファイルに関するメタデータ。 必須です。 |
| destinationFileName |
string |
宛先ファイル名。 |
応答
成功した場合、この呼び出しは応答を返 204 No Content します。
例
要求
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();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
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);
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
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];
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
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();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
//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)
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
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
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
応答
HTTP/1.1 204 No Content