TableColumnCollection: add
本文内容
命名空间:microsoft.graph
向表中添加新列。
Permissions
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Files.ReadWrite
委派(个人 Microsoft 帐户)
不支持。
应用程序
不支持。
HTTP 请求
POST /me/drive/items/{id}/workbook/tables/{id|name}/columns/add
POST /me/drive/root:/{item-path}:/workbook/tables/{id|name}/columns/add
POST /me/drive/items/{id}/workbook/worksheets/{id|name}/tables/{id|name}/columns/add
POST /me/drive/root:/{item-path}:/workbook/worksheets/{id|name}/tables/{id|name}/columns/add
名称
说明
Authorization
Bearer {token}。必需。
Workbook-Session-Id
确定是否保留更改的工作簿会话 ID。可选。
请求正文
在请求正文中,提供具有以下参数的 JSON 对象。
参数
类型
Description
index
Int32
指定新列的相对位置。之前位于此位置的列向右移动。索引值应等于或小于最后一列的索引值,因此不能用于在表末尾附加列。从零开始编制索引。
values
Json
可选。未设置格式的表列值的二维数组。
name
string
name
响应
如果成功,此方法在 200 OK 响应正文中返回 响应代码和 WorkbookTableColumn 对象。
示例
下面是一个如何调用此 API 的示例。
请求
下面是一个请求示例。
POST https://graph.microsoft.com/v1.0/me/drive/items/{id}/workbook/tables/{id|name}/columns/add
Content-type: application/json
{
"index": 3,
"values": [
{
}
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var index = 3;
var values = JsonDocument.Parse("[{}]");
await graphClient.Me.Drive.Items["{driveItem-id}"].Workbook.Tables["{workbookTable-id}"].Columns
.Add(index,values,null)
.Request()
.PostAsync();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
const options = {
authProvider,
};
const client = Client.init(options);
const workbookTableColumn = {
index: 3,
values: [
{
}
]
};
await client.api('/me/drive/items/{id}/workbook/tables/{id|name}/columns/add')
.post(workbookTableColumn);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/drive/items/{id}/workbook/tables/{id|name}/columns/add"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
int32_t index = 3;
payloadDictionary[@"index"] = index;
NSMutableArray *valuesList = [[NSMutableArray alloc] init];
MSGraphJson *values = [[MSGraphJson alloc] init];
[valuesList addObject: values];
payloadDictionary[@"values"] = valuesList;
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();
int index = 3;
LinkedList<JsonElement> valuesList = new LinkedList<JsonElement>();
JsonElement values = new JsonObject();
valuesList.add(values);
graphClient.me().drive().items("{id}").workbook().tables("{id|name}").columns()
.add(WorkbookTableColumnAddParameterSet
.newBuilder()
.withIndex(index)
.withValues(values)
.withName(null)
.build())
.buildRequest()
.post();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
响应
这是一个示例响应。注意:为提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "99",
"name": "name-value",
"index": 99,
"values": "values-value"
}