contentType の更新
-
[アーティクル]
-
-
名前空間: microsoft.graph
コンテンツ タイプ [contentType][を更新します]。
アクセス許可
この API を呼び出すには、次のいずれかのアクセス許可が必要です。アクセス許可の選択方法などの詳細については、「アクセス許可」を参照してください。
| アクセス許可の種類 |
アクセス許可 (特権の小さいものから大きいものへ) |
| 委任 (職場または学校のアカウント) |
Sites.Manage.All、Sites.FullControl.All |
| 委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
| アプリケーション |
Sites.Manage.All、Sites.FullControl.All |
HTTP 要求
PATCH /sites/{site-id}/contentTypes/{contentType-id}
PATCH /sites/{site-id}/lists/{list-id}/contentTypes/{contentType-id}
| 名前 |
説明 |
| Authorization |
ベアラー {token}。必須。 |
| Content-Type |
application/json. Required. |
要求本文
要求本文で、更新する contentType リソースの JSON 表記を指定します。
応答
成功した場合、このメソッドは応答コードと、応答本文で 200 OK [更新された contentType][] オブジェクトを返します。
例
要求
PATCH https://graph.microsoft.com/v1.0/sites/{site-id}/contentTypes/{contentType-id}
Content-Type: application/json
{
"name": "updatedCt",
"documentSet": {
"shouldPrefixNameToFile": true,
"allowedContentTypes": [{
"id": "0x0101",
"name": "Document"
}],
"defaultContents": [{
"fileName": "a.txt",
"contentType": {
"id": "0x0101"
}
},
{
"fileName": "b.txt",
"contentType": {
"id": "0x0101"
}
}
],
"sharedColumns": [{
"name": "Description",
"id": "cbb92da4-fd46-4c7d-af6c-3128c2a5576e"
},
{
"name": "Address",
"id": "fc2e188e-ba91-48c9-9dd3-16431afddd50"
}
],
"welcomePageColumns": [{
"name": "Address",
"id": "fc2e188e-ba91-48c9-9dd3-16431afddd50"
}]
}
}
const options = {
authProvider,
};
const client = Client.init(options);
const contentType = {
name: 'updatedCt',
documentSet: {
shouldPrefixNameToFile: true,
allowedContentTypes: [{
id: '0x0101',
name: 'Document'
}],
defaultContents: [{
fileName: 'a.txt',
contentType: {
id: '0x0101'
}
},
{
fileName: 'b.txt',
contentType: {
id: '0x0101'
}
}
],
sharedColumns: [{
name: 'Description',
id: 'cbb92da4-fd46-4c7d-af6c-3128c2a5576e'
},
{
name: 'Address',
id: 'fc2e188e-ba91-48c9-9dd3-16431afddd50'
}
],
welcomePageColumns: [{
name: 'Address',
id: 'fc2e188e-ba91-48c9-9dd3-16431afddd50'
}]
}
};
await client.api('/sites/{site-id}/contentTypes/{contentType-id}')
.update(contentType);
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/{site-id}/contentTypes/{contentType-id}"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphContentType *contentType = [[MSGraphContentType alloc] init];
[contentType setName:@"updatedCt"];
MSGraphDocumentSet *documentSet = [[MSGraphDocumentSet alloc] init];
[documentSet setShouldPrefixNameToFile: true];
NSMutableArray *allowedContentTypesList = [[NSMutableArray alloc] init];
MSGraphContentTypeInfo *allowedContentTypes = [[MSGraphContentTypeInfo alloc] init];
[allowedContentTypes setId:@"0x0101"];
[allowedContentTypes setName:@"Document"];
[allowedContentTypesList addObject: allowedContentTypes];
[documentSet setAllowedContentTypes:allowedContentTypesList];
NSMutableArray *defaultContentsList = [[NSMutableArray alloc] init];
MSGraphDocumentSetContent *defaultContents = [[MSGraphDocumentSetContent alloc] init];
[defaultContents setFileName:@"a.txt"];
MSGraphDocumentSetContent *contentType = [[MSGraphDocumentSetContent alloc] init];
[contentType setId:@"0x0101"];
[defaultContents setContentType:contentType];
[defaultContentsList addObject: defaultContents];
MSGraphDocumentSetContent *defaultContents = [[MSGraphDocumentSetContent alloc] init];
[defaultContents setFileName:@"b.txt"];
MSGraphDocumentSetContent *contentType = [[MSGraphDocumentSetContent alloc] init];
[contentType setId:@"0x0101"];
[defaultContents setContentType:contentType];
[defaultContentsList addObject: defaultContents];
[documentSet setDefaultContents:defaultContentsList];
NSMutableArray *sharedColumnsList = [[NSMutableArray alloc] init];
MSGraphColumnDefinition *sharedColumns = [[MSGraphColumnDefinition alloc] init];
[sharedColumns setName:@"Description"];
[sharedColumns setId:@"cbb92da4-fd46-4c7d-af6c-3128c2a5576e"];
[sharedColumnsList addObject: sharedColumns];
MSGraphColumnDefinition *sharedColumns = [[MSGraphColumnDefinition alloc] init];
[sharedColumns setName:@"Address"];
[sharedColumns setId:@"fc2e188e-ba91-48c9-9dd3-16431afddd50"];
[sharedColumnsList addObject: sharedColumns];
[documentSet setSharedColumns:sharedColumnsList];
NSMutableArray *welcomePageColumnsList = [[NSMutableArray alloc] init];
MSGraphColumnDefinition *welcomePageColumns = [[MSGraphColumnDefinition alloc] init];
[welcomePageColumns setName:@"Address"];
[welcomePageColumns setId:@"fc2e188e-ba91-48c9-9dd3-16431afddd50"];
[welcomePageColumnsList addObject: welcomePageColumns];
[documentSet setWelcomePageColumns:welcomePageColumnsList];
[contentType setDocumentSet:documentSet];
NSError *error;
NSData *contentTypeData = [contentType getSerializedDataWithError:&error];
[urlRequest setHTTPBody:contentTypeData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewContentType()
name := "updatedCt"
requestBody.SetName(&name)
documentSet := msgraphsdk.NewDocumentSet()
requestBody.SetDocumentSet(documentSet)
shouldPrefixNameToFile := true
documentSet.SetShouldPrefixNameToFile(&shouldPrefixNameToFile)
documentSet.SetAllowedContentTypes( []ContentTypeInfo {
msgraphsdk.NewContentTypeInfo(),
id := "0x0101"
SetId(&id)
name := "Document"
SetName(&name)
}
documentSet.SetDefaultContents( []DocumentSetContent {
msgraphsdk.NewDocumentSetContent(),
fileName := "a.txt"
SetFileName(&fileName)
contentType := msgraphsdk.NewContentTypeInfo()
SetContentType(contentType)
id := "0x0101"
contentType.SetId(&id)
msgraphsdk.NewDocumentSetContent(),
fileName := "b.txt"
SetFileName(&fileName)
contentType := msgraphsdk.NewContentTypeInfo()
SetContentType(contentType)
id := "0x0101"
contentType.SetId(&id)
}
documentSet.SetSharedColumns( []ColumnDefinition {
msgraphsdk.NewColumnDefinition(),
name := "Description"
SetName(&name)
id := "cbb92da4-fd46-4c7d-af6c-3128c2a5576e"
SetId(&id)
msgraphsdk.NewColumnDefinition(),
name := "Address"
SetName(&name)
id := "fc2e188e-ba91-48c9-9dd3-16431afddd50"
SetId(&id)
}
documentSet.SetWelcomePageColumns( []ColumnDefinition {
msgraphsdk.NewColumnDefinition(),
name := "Address"
SetName(&name)
id := "fc2e188e-ba91-48c9-9dd3-16431afddd50"
SetId(&id)
}
siteId := "site-id"
contentTypeId := "contentType-id"
graphClient.SitesById(&siteId).ContentTypesById(&contentTypeId).Patch(requestBody)
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
Import-Module Microsoft.Graph.Sites
$params = @{
Name = "updatedCt"
DocumentSet = @{
ShouldPrefixNameToFile = $true
AllowedContentTypes = @(
@{
Id = "0x0101"
Name = "Document"
}
)
DefaultContents = @(
@{
FileName = "a.txt"
ContentType = @{
Id = "0x0101"
}
}
@{
FileName = "b.txt"
ContentType = @{
Id = "0x0101"
}
}
)
SharedColumns = @(
@{
Name = "Description"
Id = "cbb92da4-fd46-4c7d-af6c-3128c2a5576e"
}
@{
Name = "Address"
Id = "fc2e188e-ba91-48c9-9dd3-16431afddd50"
}
)
WelcomePageColumns = @(
@{
Name = "Address"
Id = "fc2e188e-ba91-48c9-9dd3-16431afddd50"
}
)
}
}
Update-MgSiteContentType -SiteId $siteId -ContentTypeId $contentTypeId -BodyParameter $params
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
応答
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "0x0101009B237E76EF94DC49B4E58139041E7C60",
"description": "",
"eTag": "\"7\"",
"group": "Custom Content Types",
"hidden": false,
"name": "testdoc",
"parentId": "0x0101",
"base": {
"id": "0x0101",
"name": "Document"
}
}