主题
修改表单
注意
表单相关接口目前处于 alpha 阶段,接口可能会随时调整,请慎重使用。
修改金山文档表单
基本信息
请求方法:PUT
请求路径:/api/v1/openapi/personal/forms/:form_id
请求主机:developer.kdocs.cn
限流频次
应用类型 | 限额 |
---|---|
测试应用 | 500 次/天 |
正式应用 | 100,000 次/天 |
权限范围
权限值 | 显示名称 | 权限说明 |
---|---|---|
update_form | 修改表单 | 修改表单 |
Path 参数
参数 | 必须 | 类型 | 说明 |
---|---|---|---|
form_id | 是 | string | 表单 id |
Query 参数
参数 | 必须 | 类型 | 说明 |
---|---|---|---|
access_token | 是 | string |
Body 参数
参数 | 必须 | 类型 | 说明 |
---|---|---|---|
title | 是 | string | 表单标题 |
subtitle | 否 | string | 表单副标题 |
config | 否 | formConfig {} | 表单设置 |
hidden | 否 | boolean | 是否在表单列表隐藏当前创建的表单( 投票 类型的表单传 true ) |
answer_items | 否 | answerItems {} | 表单结束语设置 |
questions | 是 | questions {} | 表单题目 |
questions_sections | 否 | questionSections {} | 表单题目 |
提示
questions
为一个 map<string, question>
,key
为题目 ID,value
为题目内容。
提示
question_sections
为一个对象数组,用来控制表单的展现形式的,尤其注意可以用来控制表单中题目的展示顺序。可以将所有要显示的题目按照顺序,放到一个 question_sections
内部。以下为一个示例:
{
// 表单内的其它数据先省略,其它字段省略
"question_sections": [
{
"id": "question_section_id",
"questions": [
{
"qid": "question_id_1",
},
{
"qid": "question_id_2",
}
// 将所有要显示的题目,delete = false 的,都放到这一个元素内
]
}
]
}
开放平台提供的题目类型及格式定义如下:
提示
questions
为一个 map<string, question>
,key
为题目 ID,value
为题目内容。
此处仅列举 question
即 value
部分
不同题型通过 type
字段来标识
填空题类
填空类题目包含如下类型 type
:
input
单行填空题-单行填空multiInput
多行填空题-多行填空floatInput
数字填空题-数字telphone
填空题-手机号手机号star
评分题date
填空题-日期日期time
时间填空题-时间signatures
填空题-电子签名电子签名idcard
:填空题-身份证号email
邮箱填空题-邮箱scanCode
填空题-扫码输入扫码输入multiStepInput
多段填空___第二空___address
填空题-地址地址
参数格式:
参数 | 必须 | 类型 | 说明 |
---|---|---|---|
title | 是 | string | 题目标题 |
type | 是 | string | 题目类型,示例: input 填空题 |
need | 否 | boolean | 是否必答 |
hidden | 否 | boolean | 是否隐藏 |
示例:
{
"questions": {
"3t56gf": {
"title": "填空题-单行填空",
"type": "input",
"need": true,
"hidden": false,
"delete": false
}
}
}
选择题类
select
选择题-单选题doubleSelect
多选选择题pullSelect
选择题-下拉题子问题multiSelect
选择题-多段选择
参数格式:
参数 | 必须 | 类型 | 说明 |
---|---|---|---|
title | 是 | string | 题目标题 |
type | 是 | string | 题目类型,示例: input 填空题 |
need | 否 | boolean | 是否必答 |
hidden | 否 | boolean | 是否隐藏 |
selects | 是 | selects[] | 选项列表 |
请求示例:
{
"questions": {
"2agiq4": {
"title": "选择题-多选题",
"type": "doubleSelect",
"need": false,
"hidden": false,
"delete": false,
"selects": [
{
"itemId": "k17j6v",
"text": "11"
},
{
"itemId": "i4ijyw",
"text": "22"
}
]
}
}
}
附件类
file
上传单个附件multiFile
上传多份附件newImage
上传单张图片newMultiImage
上传多张图片
参数格式:
参数 | 必须 | 类型 | 说明 |
---|---|---|---|
title | 是 | string | 题目标题 |
type | 是 | string | 题目类型,示例: input 填空题 |
need | 否 | boolean | 是否必答 |
hidden | 否 | boolean | 是否隐藏 |
fileSizeLimit | 否 | integer | 附件大小限制 |
fileAcceptType | 否 | string[] | 附件类型约束,示例: ["word", "image"] |
subItems | 是 | subItems[] | 附件子项列表 |
请求示例:
{
"questions": {
"7nfwow": {
"title": "图片题-单张",
"type": "newImage",
"need": false,
"delete": false,
"subItems": [
{
"itemId": "la0sol",
"sort": 1,
"text": "图片1"
}
],
"fileAcceptType": null,
"fileSizeLimit": 100
}
}
}
量表题类
scale
量表题matrixScale
矩阵量表题
参数格式:
参数 | 必须 | 类型 | 说明 |
---|---|---|---|
title | 是 | string | 题目标题 |
type | 是 | string | 题目类型,示例: input 填空题 |
need | 否 | boolean | 是否必答 |
hidden | 否 | boolean | 是否隐藏 |
subItems | 是 | scaleSubItems[] | 量表选项列表 |
请求示例:
{
"questions": {
"v45ovc": {
"title": "矩阵量表题",
"type": "matrixScale",
"need": false,
"delete": false,
"subItems": [
{
"itemId": "fapyqz",
"sort": 0,
"text": "子标题1",
"scaleSelects": [
{
"itemId": "z7978q",
"text": "1",
},
{
"itemId": "p32a9g",
"text": "2",
},
{
"itemId": "fxa687",
"text": "3",
},
{
"itemId": "1g1m8d",
"text": "4",
},
{
"itemId": "8yopc0",
"text": "5",
}
],
"checkStatus": 0
},
{
"itemId": "i7vcug",
"sort": 1,
"text": "子标题2",
"scaleSelects": [
{
"itemId": "p77jax",
"text": "1",
},
{
"itemId": "svak5x",
"text": "2",
},
{
"itemId": "silc52",
"text": "3",
},
{
"itemId": "49ig0h",
"text": "4",
},
{
"itemId": "zzt2jw",
"text": "5",
}
],
"checkStatus": 0
}
]
}
}
}
注意
需要注意的是,表单的更新为增量更新,如果某题目在之前存在,现在要删除,要将这个题目也上传回来,修改其 delete
字段为 true
。这样才能将原来的题目删除掉。
返回参数
参数 | 必须 | 类型 | 说明 |
---|---|---|---|
code | 是 | integer | 错误码 |
data | 是 | data {} | 响应数据 |
示例
请求示例
curl --request PUT \
--url 'https://developer.kdocs.cn/api/v1/openapi/personal/forms/JxdxSDJpnZKRRr0dEKZRuJ_FoonpnyvgzPfYd2nVJQLGW_Di8Xw5GnY7rcAOCeZpWWEbCZYH0Dlgx4bYsSRayQ?access_token=kvqxrspxjctdojjqdildjhonzwusaquc' \
--header 'Content-Type: application/json' \
--data '{"title":"interaction_vote","config":{"varied_config":{"vote_show_time":"","is_vote":true,"is_not_write_excel":true,"information_fill_notify":false},"check_login":false,"check_once":false,"can_secret_vote":false,"expire":0},"hidden":false,"questions":{"1855622480":{"id":"1855622480","title":"123","type":"select","selects":[{"itemId":"1","text":"1"},{"itemId":"2","text":"2"}],"need":true,"hidden":false}},"answer_items":{"closing_remark_text":""},"subtitle":""}'
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"title\":\"interaction_vote\",\"config\":{\"varied_config\":{\"vote_show_time\":\"\",\"is_vote\":true,\"is_not_write_excel\":true,\"information_fill_notify\":false},\"check_login\":false,\"check_once\":false,\"can_secret_vote\":false,\"expire\":0},\"hidden\":false,\"questions\":{\"1855622480\":{\"id\":\"1855622480\",\"title\":\"123\",\"type\":\"select\",\"selects\":[{\"itemId\":\"1\",\"text\":\"1\"},{\"itemId\":\"2\",\"text\":\"2\"}],\"need\":true,\"hidden\":false}},\"answer_items\":{\"closing_remark_text\":\"\"},\"subtitle\":\"\"}");
Request request = new Request.Builder()
.url("https://developer.kdocs.cn/api/v1/openapi/personal/forms/JxdxSDJpnZKRRr0dEKZRuJ_FoonpnyvgzPfYd2nVJQLGW_Di8Xw5GnY7rcAOCeZpWWEbCZYH0Dlgx4bYsSRayQ?access_token=kvqxrspxjctdojjqdildjhonzwusaquc")
.put(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/forms/JxdxSDJpnZKRRr0dEKZRuJ_FoonpnyvgzPfYd2nVJQLGW_Di8Xw5GnY7rcAOCeZpWWEbCZYH0Dlgx4bYsSRayQ?access_token=kvqxrspxjctdojjqdildjhonzwusaquc"
payload := strings.NewReader("{\"title\":\"interaction_vote\",\"config\":{\"varied_config\":{\"vote_show_time\":\"\",\"is_vote\":true,\"is_not_write_excel\":true,\"information_fill_notify\":false},\"check_login\":false,\"check_once\":false,\"can_secret_vote\":false,\"expire\":0},\"hidden\":false,\"questions\":{\"1855622480\":{\"id\":\"1855622480\",\"title\":\"123\",\"type\":\"select\",\"selects\":[{\"itemId\":\"1\",\"text\":\"1\"},{\"itemId\":\"2\",\"text\":\"2\"}],\"need\":true,\"hidden\":false}},\"answer_items\":{\"closing_remark_text\":\"\"},\"subtitle\":\"\"}")
req, _ := http.NewRequest("PUT", 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 = "{\"title\":\"interaction_vote\",\"config\":{\"varied_config\":{\"vote_show_time\":\"\",\"is_vote\":true,\"is_not_write_excel\":true,\"information_fill_notify\":false},\"check_login\":false,\"check_once\":false,\"can_secret_vote\":false,\"expire\":0},\"hidden\":false,\"questions\":{\"1855622480\":{\"id\":\"1855622480\",\"title\":\"123\",\"type\":\"select\",\"selects\":[{\"itemId\":\"1\",\"text\":\"1\"},{\"itemId\":\"2\",\"text\":\"2\"}],\"need\":true,\"hidden\":false}},\"answer_items\":{\"closing_remark_text\":\"\"},\"subtitle\":\"\"}"
headers = { 'Content-Type': "application/json" }
conn.request("PUT", "/api/v1/openapi/personal/forms/JxdxSDJpnZKRRr0dEKZRuJ_FoonpnyvgzPfYd2nVJQLGW_Di8Xw5GnY7rcAOCeZpWWEbCZYH0Dlgx4bYsSRayQ?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/forms/JxdxSDJpnZKRRr0dEKZRuJ_FoonpnyvgzPfYd2nVJQLGW_Di8Xw5GnY7rcAOCeZpWWEbCZYH0Dlgx4bYsSRayQ?access_token=kvqxrspxjctdojjqdildjhonzwusaquc",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => "{\"title\":\"interaction_vote\",\"config\":{\"varied_config\":{\"vote_show_time\":\"\",\"is_vote\":true,\"is_not_write_excel\":true,\"information_fill_notify\":false},\"check_login\":false,\"check_once\":false,\"can_secret_vote\":false,\"expire\":0},\"hidden\":false,\"questions\":{\"1855622480\":{\"id\":\"1855622480\",\"title\":\"123\",\"type\":\"select\",\"selects\":[{\"itemId\":\"1\",\"text\":\"1\"},{\"itemId\":\"2\",\"text\":\"2\"}],\"need\":true,\"hidden\":false}},\"answer_items\":{\"closing_remark_text\":\"\"},\"subtitle\":\"\"}",
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({
"title": "interaction_vote",
"config": {
"varied_config": {
"vote_show_time": "",
"is_vote": true,
"is_not_write_excel": true,
"information_fill_notify": false
},
"check_login": false,
"check_once": false,
"can_secret_vote": false,
"expire": 0
},
"hidden": false,
"questions": {
"1855622480": {
"id": "1855622480",
"title": "123",
"type": "select",
"selects": [
{
"itemId": "1",
"text": "1"
},
{
"itemId": "2",
"text": "2"
}
],
"need": true,
"hidden": false
}
},
"answer_items": {
"closing_remark_text": ""
},
"subtitle": ""
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("PUT", "https://developer.kdocs.cn/api/v1/openapi/personal/forms/JxdxSDJpnZKRRr0dEKZRuJ_FoonpnyvgzPfYd2nVJQLGW_Di8Xw5GnY7rcAOCeZpWWEbCZYH0Dlgx4bYsSRayQ?access_token=kvqxrspxjctdojjqdildjhonzwusaquc");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);
const http = require("https");
const options = {
"method": "PUT",
"hostname": "developer.kdocs.cn",
"port": null,
"path": "/api/v1/openapi/personal/forms/JxdxSDJpnZKRRr0dEKZRuJ_FoonpnyvgzPfYd2nVJQLGW_Di8Xw5GnY7rcAOCeZpWWEbCZYH0Dlgx4bYsSRayQ?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({
title: 'interaction_vote',
config: {
varied_config: {
vote_show_time: '',
is_vote: true,
is_not_write_excel: true,
information_fill_notify: false
},
check_login: false,
check_once: false,
can_secret_vote: false,
expire: 0
},
hidden: false,
questions: {
'1855622480': {
id: '1855622480',
title: '123',
type: 'select',
selects: [{itemId: '1', text: '1'}, {itemId: '2', text: '2'}],
need: true,
hidden: false
}
},
answer_items: {closing_remark_text: ''},
subtitle: ''
}));
req.end();
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(hnd, CURLOPT_URL, "https://developer.kdocs.cn/api/v1/openapi/personal/forms/JxdxSDJpnZKRRr0dEKZRuJ_FoonpnyvgzPfYd2nVJQLGW_Di8Xw5GnY7rcAOCeZpWWEbCZYH0Dlgx4bYsSRayQ?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, "{\"title\":\"interaction_vote\",\"config\":{\"varied_config\":{\"vote_show_time\":\"\",\"is_vote\":true,\"is_not_write_excel\":true,\"information_fill_notify\":false},\"check_login\":false,\"check_once\":false,\"can_secret_vote\":false,\"expire\":0},\"hidden\":false,\"questions\":{\"1855622480\":{\"id\":\"1855622480\",\"title\":\"123\",\"type\":\"select\",\"selects\":[{\"itemId\":\"1\",\"text\":\"1\"},{\"itemId\":\"2\",\"text\":\"2\"}],\"need\":true,\"hidden\":false}},\"answer_items\":{\"closing_remark_text\":\"\"},\"subtitle\":\"\"}");
CURLcode ret = curl_easy_perform(hnd);
var client = new RestClient("https://developer.kdocs.cn/api/v1/openapi/personal/forms/JxdxSDJpnZKRRr0dEKZRuJ_FoonpnyvgzPfYd2nVJQLGW_Di8Xw5GnY7rcAOCeZpWWEbCZYH0Dlgx4bYsSRayQ?access_token=kvqxrspxjctdojjqdildjhonzwusaquc");
var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\"title\":\"interaction_vote\",\"config\":{\"varied_config\":{\"vote_show_time\":\"\",\"is_vote\":true,\"is_not_write_excel\":true,\"information_fill_notify\":false},\"check_login\":false,\"check_once\":false,\"can_secret_vote\":false,\"expire\":0},\"hidden\":false,\"questions\":{\"1855622480\":{\"id\":\"1855622480\",\"title\":\"123\",\"type\":\"select\",\"selects\":[{\"itemId\":\"1\",\"text\":\"1\"},{\"itemId\":\"2\",\"text\":\"2\"}],\"need\":true,\"hidden\":false}},\"answer_items\":{\"closing_remark_text\":\"\"},\"subtitle\":\"\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
返回示例
{
"code": 0,
"data": {}
}
错误码
请参考错误码说明