contentType:addCopy
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
将内容类型 的副本从网站添加到列表。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
Sites.Manage.All、Sites.FullControl.All |
| 委派(个人 Microsoft 帐户) |
不支持。 |
| 应用程序 |
Sites.Manage.All、Sites.FullControl.All |
HTTP 请求
POST /sites/{site-id}/lists/{list-id}/contentTypes/addCopy
| 名称 |
说明 |
| Authorization |
Bearer {token}。必需。 |
| Content-Type |
application/json. Required. |
请求正文
在请求正文中,提供参数的 JSON 表示形式。
下表显示了可用于此操作的参数。
| 参数 |
类型 |
说明 |
| contentType |
string |
将复制到列表的网站内容类型的规范 URL。 必需。 |
响应
如果成功,此调用在响应 201 Created 正文中返回 响应代码和 contentType 对象。
示例
请求
POST https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}/contentTypes/addCopy
Content-Type: application/json
{
"contentType": "https://graph.microsoft.com/beta/sites/id/contentTypes/0x0101"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var contentType = "https://graph.microsoft.com/beta/sites/id/contentTypes/0x0101";
await graphClient.Sites["{site-id}"].Lists["{list-id}"].ContentTypes
.AddCopy(contentType)
.Request()
.PostAsync();
const options = {
authProvider,
};
const client = Client.init(options);
const contentType = {
contentType: 'https://graph.microsoft.com/beta/sites/id/contentTypes/0x0101'
};
await client.api('/sites/{site-id}/lists/{list-id}/contentTypes/addCopy')
.version('beta')
.post(contentType);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/sites/{site-id}/lists/{list-id}/contentTypes/addCopy"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
NSString *contentType = @"https://graph.microsoft.com/beta/sites/id/contentTypes/0x0101";
payloadDictionary[@"contentType"] = contentType;
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];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
String contentType = "https://graph.microsoft.com/beta/sites/id/contentTypes/0x0101";
graphClient.sites("{site-id}").lists("{list-id}").contentTypes()
.addCopy(ContentTypeAddCopyParameterSet
.newBuilder()
.withContentType(contentType)
.build())
.buildRequest()
.post();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewContentTypeRequestBody()
contentType := "https://graph.microsoft.com/beta/sites/id/contentTypes/0x0101"
requestBody.SetContentType(&contentType)
siteId := "site-id"
listId := "list-id"
result, err := graphClient.SitesById(&siteId).ListsById(&listId).ContentTypes().AddCopy(site-id, list-id).Post(requestBody)
Import-Module Microsoft.Graph.Sites
$params = @{
ContentType = "https://graph.microsoft.com/beta/sites/id/contentTypes/0x0101"
}
Add-MgSiteListContentTypeCopy -SiteId $siteId -ListId $listId -BodyParameter $params
响应
HTTP/1.1 201 Created
{
"id": "0x0101",
"description": "Create a new custom CSR JavaScript Display Template.",
"group": "Display Template Content Types",
"hidden": false,
"name": "JavaScript Display Template",
"parentId": "0x01",
"readOnly": false,
"sealed": false,
"base": {
"id": "0x01",
"description": "Create a new custom CSR JavaScript Display Template.",
"group": "Display Template Content Types",
"hidden": false,
"name": "JavaScript Display Template",
"readOnly": false,
"sealed": false
}
}