Chart: setPosition
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
相对于工作表上的单元格放置图表。
Permissions
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Files.ReadWrite
委派(个人 Microsoft 帐户)
Files.ReadWrite
应用程序
不支持。
HTTP 请求
POST /me/drive/items/{id}/workbook/worksheets/{id|name}/charts/{name}/setPosition
POST /me/drive/root:/{item-path}:/workbook/worksheets/{id|name}/charts/{name}/setPosition
名称
说明
Authorization
Bearer {token}。必需。
Workbook-Session-Id
确定是否保留更改的工作簿会话 ID。可选。
请求正文
在请求正文中,提供具有以下参数的 JSON 对象。
参数
类型
Description
startCell
string
起始单元格。这是图表将移动到的位置。起始单元格为左上角或右上角的单元格,具体取决于用户的从右到左显示设置。
endCell
string
可选。结束单元格。如果已指定,图表的宽度和高度将设置为完全覆盖此单元格/区域。
响应
如果成功,此方法返回 200 OK 响应代码。它不在响应正文中返回任何内容。
示例
下面是一个如何调用此 API 的示例。
请求
下面是一个请求示例。
POST https://graph.microsoft.com/beta/me/drive/items/{id}/workbook/worksheets/{id|name}/charts/{name}/setPosition
Content-type: application/json
{
"startCell": "startCell-value",
"endCell": "endCell-value"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var startCell = JsonDocument.Parse(@"""startCell-value""");
var endCell = JsonDocument.Parse(@"""endCell-value""");
await graphClient.Me.Drive.Items["{driveItem-id}"].Workbook.Worksheets["{workbookWorksheet-id}"].Charts["{workbookChart-id}"]
.SetPosition(startCell,endCell)
.Request()
.PostAsync();
const options = {
authProvider,
};
const client = Client.init(options);
const setPosition = {
startCell: 'startCell-value',
endCell: 'endCell-value'
};
await client.api('/me/drive/items/{id}/workbook/worksheets/{id|name}/charts/{name}/setPosition')
.version('beta')
.post(setPosition);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/drive/items/{id}/workbook/worksheets/{id|name}/charts/{name}/setPosition"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
NSString *startCell = @"startCell-value";
payloadDictionary[@"startCell"] = startCell;
NSString *endCell = @"endCell-value";
payloadDictionary[@"endCell"] = endCell;
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();
JsonElement startCell = JsonParser.parseString("startCell-value");
JsonElement endCell = JsonParser.parseString("endCell-value");
graphClient.me().drive().items("{id}").workbook().worksheets("{id|name}").charts("{name}")
.setPosition(WorkbookChartSetPositionParameterSet
.newBuilder()
.withStartCell(startCell)
.withEndCell(endCell)
.build())
.buildRequest()
.post();
响应
下面是一个响应示例。
HTTP/1.1 200 OK