# 移动行列

该接口用于移动行或列。行或列被移动到目标位置后，原本在目标位置的行列会对应右移或下移。

## 请求

基本 | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/sheets/v3/spreadsheets/:spreadsheet_token/sheets/:sheet_id/move_dimension
HTTP Method | POST
接口频率限制 | [100 次/分钟](https://open.feishu.cn/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
支持的应用类型 | Custom App、Store App
权限要求<br>**调用该 API 所需的权限。开启其中任意一项权限即可调用**<br>开启任一权限即可 | 查看、评论、编辑和管理云空间中所有文件(drive:drive)<br>查看、评论、编辑和管理电子表格(sheets:spreadsheet)

### 请求头

名称 | 类型 | 必填 | 描述
---|---|---|---
Authorization | string | 是 | `tenant_access_token`<br>或<br>`user_access_token`<br>**值格式**："Bearer `access_token`"<br>**示例值**："Bearer u-7f1bcd13fc57d46bac21793a18e560"<br>[了解更多：如何选择与获取 access token](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)
Content-Type | string | 是 | **固定值**："application/json; charset=utf-8"

### 路径参数

名称 | 类型 | 描述
---|---|---
spreadsheet_token | string | 电子表格的 token。可通过以下两种方式获取。了解更多，参考[电子表格概述](https://open.feishu.cn/document/ukTMukTMukTM/uATMzUjLwEzM14CMxMTN/overview)。<br>-  电子表格的 URL：https://sample.feishu.cn/sheets/==Iow7sNNEphp3WbtnbCscPqabcef==<br>- 调用[获取文件夹中的文件清单](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/drive-v1/file/list)<br>**示例值**："Iow7sNNEphp3WbtnbCscPqabcef"
sheet_id | string | 工作表的 ID。调用[获取工作表](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/sheets-v3/spreadsheet-sheet/query)获取 ID<br>**示例值**："2jm6f6"

### 请求体

名称 | 类型 | 必填 | 描述
---|---|---|---
source | dimension | 否 | 移动源位置信息
major_dimension | string | 否 | 移动的维度。可选值：<br>- `ROWS`：行<br>- `COLUMNS`：列<br>**示例值**："ROWS"
start_index | int | 否 | 要移动的行或列的起始位置。从 0 开始计数。若 `startIndex` 为 3，则从第 4 行或列开始移动。包含第 4 行或列。<br>**示例值**：0
end_index | int | 否 | 要移动的行或列结束的位置。从 0 开始计数。若 `endIndex` 为 7，则要移动的范围至第 8 行或列结束。包含第 8 行或列。<br>示例：当 `majorDimension`为 `ROWS`、 `startIndex` 为 3、`endIndex ` 为 7 时，则移动第 4、5、6、7、8 行，共 5 行。<br>**示例值**：1
destination_index | int | 否 | 移动的目标位置行或者列<br>**示例值**：4

### 请求体示例
```json
{
    "source": {
        "major_dimension": "ROWS",
        "start_index": 0,
        "end_index": 1
    },
    "destination_index": 4
}
```

### cURL 请求示例
```bash
curl --location --request POST 'https://open.feishu.cn/open-apis/sheets/v3/spreadsheets/shtcnSUVpFeJ7Q2ycG1cHeSc/sheets/6e2914/move_dimension' \
--header 'Authorization: Bearer t-719d578dc63f6bd37e30cdb0394798a709070fec' \
--header 'Content-Type: application/json' \
--data-raw '{
    "source": {
        "major_dimension": "COLUMNS",
        "start_index": 1,
        "end_index": 3
    },
    "destination_index": 0
}'
```

## 响应

### 响应体

名称 | 类型 | 描述
---|---|---
code | int | 错误码，非 0 表示失败
msg | string | 错误描述
data | \- | \-

### 响应体示例
```json
{
    "code": 0,
    "msg": "success",
    "data": {}
}
```

### 错误码

HTTP状态码 | 错误码 | 描述 | 排查建议
---|---|---|---
400 | 1310211 | Wrong Sheet Id | 检查 sheet_id
400 | 1310202 | Wrong Range | 区域范围错误
400 | 1310229 | Wrong URL Param | 检查 url 参数
400 | 1310204 | Wrong Request Body | 检查请求体参数, 参考响应体中的错误提示
400 | 1310206 | Empty Sheet Id | 检查 sheet_id
400 | 1310218 | Locked Cell | 检查操作的是否为保护范围
400 | 1310213 | Permission Fail | 没有文档相应权限。参考[云文档常见问题](https://open.feishu.cn/document/ukTMukTMukTM/uczNzUjL3czM14yN3MTN)问题 2 和问题 3 开通应用权限和文档权限
400 | 1310214 | SpreadSheet Not Found | 检查表格 token
400 | 1310215 | Sheet Id Not Found | 检查 sheet_id
400 | 1310216 | Empty Value | 检查请求体
400 | 1310217 | Too Many Request | 检查请求是否发送过于频繁
400 | 1310219 | Cell Excess | 检查起始范围是否超限
400 | 1310235 | Retry Later | 稍后重试
500 | 1315201 | Server Error | 服务内部错误，[详询客服](https://applink.feishu.cn/client/helpdesk/open?id=6626260912531570952)
500 | 1315203 | Server Error | 服务内部错误，[详询客服](https://applink.feishu.cn/client/helpdesk/open?id=6626260912531570952)
200 | 1310234 | Marshal Error | 服务内部错误，[详询客服](https://applink.feishu.cn/client/helpdesk/open?id=6626260912531570952)
400 | 1310242 | In Mix state | 混合部署租户，文档处于冷删除状态，等待冷恢复后重试
400 | 1310249 | Spreadsheet Deleted | 恢复表格后重试

