Skip to content

创建空白文档

在指定目录下创建文档,支持的类型见类型说明

基本信息

请求方法:POST

请求路径:/api/v1/openapi/personal/files

请求主机:developer.kdocs.cn

限流频次

应用类型限额
测试应用
500 次/天
正式应用
100,000 次/天

权限范围

权限值显示名称权限说明
create_personal_files
创建个人文档
创建个人文档

Query 参数

参数必须类型说明
access_token
string

Body 参数

参数必须类型说明
filename
string
文档名称,包含扩展名,例如:demo.ksheet
parent_id
string
文档所属目录 id,与 parent_path 互斥,同时存在时优先使用 parent_id
parent_path
string[]
文档所属目录,与 parent_id 互斥,同时存在时优先使用 parent_id
path_from_root
boolean
parent_path 参数是否从 我的文档 开始,默认否

参数说明:

提示

在金山文档,存储用户个人文档的根目录为我的文档

应用名path_from_rootparent_path文档创建位置
foo
false
[]
/我的文档/应用/foo
foo
false
["bar", "baz"]
/我的文档/应用/foo/bar/baz
foo
true
[]
/我的文档
foo
true
["bar", "baz"]
/我的文档/bar/baz

提示

我们推荐您将文档创建到您的应用目录下,方便用户理解和管理。

文档类型说明

文档类型扩展名
在线表格
.ksheet
轻维表
.dbt
文档
.otl
演示
.pptx .ppt
WPS 文字
.docx .doc
WPS 表格
.xlsx .xls

返回参数

参数必须类型说明
code
integer
错误码
+
data
data {}
响应数据

示例

请求示例

curl --request POST \
	--url 'https://developer.kdocs.cn/api/v1/openapi/personal/files?access_token=kvqxrspxjctdojjqdildjhonzwusaquc' \
	--header 'Content-Type: application/json' \
	--data '{"filename":"demo.ksheet","parent_path":["path1","path2"]}'
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"filename\":\"demo.ksheet\",\"parent_path\":[\"path1\",\"path2\"]}");
Request request = new Request.Builder()
	.url("https://developer.kdocs.cn/api/v1/openapi/personal/files?access_token=kvqxrspxjctdojjqdildjhonzwusaquc")
	.post(body)
	.addHeader("Content-Type", "application/json")
	.build();

Response response = client.newCall(request).execute();
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://developer.kdocs.cn/api/v1/openapi/personal/files?access_token=kvqxrspxjctdojjqdildjhonzwusaquc"

	payload := strings.NewReader("{\"filename\":\"demo.ksheet\",\"parent_path\":[\"path1\",\"path2\"]}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
import http.client

conn = http.client.HTTPSConnection("developer.kdocs.cn")

payload = "{\"filename\":\"demo.ksheet\",\"parent_path\":[\"path1\",\"path2\"]}"

headers = { 'Content-Type': "application/json" }

conn.request("POST", "/api/v1/openapi/personal/files?access_token=kvqxrspxjctdojjqdildjhonzwusaquc", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
<?php

$curl = curl_init();

curl_setopt_array($curl, [
	CURLOPT_URL => "https://developer.kdocs.cn/api/v1/openapi/personal/files?access_token=kvqxrspxjctdojjqdildjhonzwusaquc",
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_ENCODING => "",
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 30,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => "POST",
	CURLOPT_POSTFIELDS => "{\"filename\":\"demo.ksheet\",\"parent_path\":[\"path1\",\"path2\"]}",
	CURLOPT_HTTPHEADER => [
		"Content-Type: application/json"
	],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
	echo "cURL Error #:" . $err;
} else {
	echo $response;
}
const data = JSON.stringify({
	"filename": "demo.ksheet",
	"parent_path": [
		"path1",
		"path2"
	]
});

const xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
	if (this.readyState === this.DONE) {
		console.log(this.responseText);
	}
});

xhr.open("POST", "https://developer.kdocs.cn/api/v1/openapi/personal/files?access_token=kvqxrspxjctdojjqdildjhonzwusaquc");
xhr.setRequestHeader("Content-Type", "application/json");

xhr.send(data);
const http = require("https");

const options = {
	"method": "POST",
	"hostname": "developer.kdocs.cn",
	"port": null,
	"path": "/api/v1/openapi/personal/files?access_token=kvqxrspxjctdojjqdildjhonzwusaquc",
	"headers": {
		"Content-Type": "application/json"
	}
};

const req = http.request(options, function (res) {
	const chunks = [];

	res.on("data", function (chunk) {
		chunks.push(chunk);
	});

	res.on("end", function () {
		const body = Buffer.concat(chunks);
		console.log(body.toString());
	});
});

req.write(JSON.stringify({filename: 'demo.ksheet', parent_path: ['path1', 'path2']}));
req.end();
CURL *hnd = curl_easy_init();

curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://developer.kdocs.cn/api/v1/openapi/personal/files?access_token=kvqxrspxjctdojjqdildjhonzwusaquc");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);

curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"filename\":\"demo.ksheet\",\"parent_path\":[\"path1\",\"path2\"]}");

CURLcode ret = curl_easy_perform(hnd);
var client = new RestClient("https://developer.kdocs.cn/api/v1/openapi/personal/files?access_token=kvqxrspxjctdojjqdildjhonzwusaquc");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\"filename\":\"demo.ksheet\",\"parent_path\":[\"path1\",\"path2\"]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

返回示例

{
  "code": 0,
  "data": {
    "id": {
      "open_id": "JxdxSDJpnZKRRr0dEKZRuKzClBub7Uz7m1caY_YSxZg",
      "union_id": "-9Yu8Qo2oJirjqhvNofycKzClBub7Uz7m1caY_YSxZg"
    },
    "space": "ok"
  }
}

错误码

请参考错误码说明