1 前置信息
产品手册,一般会撰写API文档,关于API文档编写,一般包括几个方面:API调用方式、具体URL、入参及出参等。
此次关于调用示例选用方式为curl,curl 是一种命令行工具,作用是发出网络请求,然后获取数据,显示在"标准输出"(stdout)上面。它支持多种协议。
curl 默认的 HTTP 动词是 GET
-X 参数可以支持其他动词。
--user name:password ,如果需要认证,可按照这种方式输入用户密码
-d, --data DATA HTTP POST data (H)
-H, --header LINE Custom header to pass to server (H)
-o, --output FILE Write output to <file> instead of stdout
2 具体模板
## XX导入导出
对于资源发布的需求,可以使用本节介绍的导入导出功能支持。目前,仅支持一个XX的导入和导出。
### 前提条件
您的 ** XX 版本必须 >= 1.1.0**
### 导出
- `POST http://host:port/api/xx/export/{type}`
- URL Path Variable
- `type`: 取值为 `xx`
- Basic Auth 认证
- `Content-Type`: `application`/ `json`
- HTTP Body 是 `json`,内容如下:
- `{ "project":"[项目名]","dataset_name":"[数据集名称]" }`
- Curl示例如下:
```sh
curl -XPOST \
--user [用户名]:[密码] http://host:port/api/xx/export/{datasetType} \
-H 'Content-Type:application/json;charset=utf8' \
-d '{"project":"learn_kylin","dataset_name":"dataset1"}' \
-o export_dataset.json
```
> 命令解释:调用接口,将相应的 json 数据存入到当前目录的export_dataset.json 中