保利威文档中心

帮助中心

批量创建问卷(支持多频道同时创建)

更新时间:2026-06-18 10:39:08

接口描述

1、支持批量创建问卷(支持多频道同时创建)
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议

接口URL

http://api.polyv.net/live/v4/channel/questionnaire/create-batch

在线API调用

请求方式

POST

接口约束

1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看

请求参数描述

参数名 必选 类型 说明
appId true String 账号appId【详见获取密钥
timestamp true Long 当前13位毫秒级时间戳,3分钟内有效
sign true String 签名,为32位大写的MD5值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据【详见签名生成规则

请求体参数描述

参数名 必选 类型 说明
questionnaires true Array 问卷列表(最大支持同时一次创建50个问卷)【详见questionnaires字段说明

questionnaires字段说明

参数名 必选 类型 说明
questionnaireTitle true String 问卷标题
questions true Array 题目数组 【详见questions字段说明
channelId true Integer 频道id
customQuestionnaireId false String 客户自定义问卷id
autoPublishTime false String 问卷定时自动发布时间(时间格式为"yyyy-MM-dd HH:mm";需大于当前时间1分钟以上;当autoEndTime传递时,autoPublishTime必传)
autoEndTime false String 问卷定时自动结束时间 (时间格式为"yyyy-MM-dd HH:mm";需大于autoPublishTime,当autoPublishTime必传传递时,autoEndTime必传)
privacyEnabled false String 隐私协议开关
privacyContent false String 隐私协议内容
userTags false Array 观众业务标签匹配条件,用于问卷定向弹出(仅外部授权观众生效)。传入后该问卷仅对携带任一匹配标签的外部授权观众弹出;未传或为空时保持原有问卷弹出逻辑。最多支持10个标签

questions字段说明

参数名 必选 类型 说明
name true String 题目
type true String 题目类型
R:单选
C:多选
Q:问答
J:判断题
X:评星题
scoreEnabled false String 题目是否需要评分
Y:需要
N:不需要
score false String 分数
scoreEnabled为Y时必传
answer false String 答案,需要评分的选择题才有答案,填入对应选项序号,如:A或AB
required false String 题目是否为必答
Y:必答
N:非必答
options false String[] 题目为单选题或多选题为必填,选项数组下标0-9对应答案A-J

示例

https://api.polyv.net/live/v4/channel/questionnaire/create-batch?appId=frlr1zazn3&sign=439CDA1327558DFCF947F305D03AFA92&timestamp=1621843779393

请求体参数

{
  "questionnaires": [
    {
      "questionnaireTitle": "这里是问卷标题",
      "channelId": 10002,
      "userTags": ["vip", "registered"],
      "autoPublishTime": "2025-04-31 08:00",
      "autoEndTime": "2025-04-31 08:30",
      "questions": [
        {
          "name": "题目名称qwe1",
          "type": "R",
          "answer": "A",
          "required": "Y",
          "options": ["选项1", "选项2", "选项3"]
        }
      ]
    },
    {
      "questionnaireTitle": "这里是问卷标题2",
      "channelId": 10003,
      "questions": [
        {
          "name": "题目名称qwe2",
          "type": "R",
          "answer": "B",
          "required": "Y",
          "scoreEnabled": "Y",
          "score": 10,
          "options": ["选项1", "选项2", "选项3"]
        }
      ]
    }
  ]
}

响应参数描述

参数名 类型 说明
code Integer 响应状态码,200为成功返回,非200为失败【详见全局错误说明
status String 响应状态文本信息
message String 响应描述信息,当code为400或者500的时候,辅助描述错误原因
data Object 成功响应时为问卷基本信息 【详见data字段说明

data字段说明

参数名 类型 说明
questionnaires Array 问卷信息列表 【详见questionnaires字段说明

questionnaires字段说明

参数名 类型 说明
questionnaireId String 问卷ID
questionIds String[] 题目ID数组
channelId Integer 频道id
questionnaireTitle String 问卷标题

Java请求示例

快速接入基础代码请下载相关依赖源码点击下载源代码 ,下载后加入到自己的源码工程中即可。测试用例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下载文件中。

强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。

private static final Logger log = LoggerFactory.getLogger(LiveInteractionTest.class);

/**
 * 设修改频道问卷
 * @throws IOException
 */
@Test
public void testAddEditQuestionnaire() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId=super.appId;
    String appSecret=super.appSecret;
    String userId = super.userId;
    String timestamp=String.valueOf(System.currentTimeMillis());
    //业务参数
    String temp = "https://api.polyv.net/live/v4/channel/questionnaire/create-batch";

    //http 调用逻辑
    Map<String,String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp",timestamp);

    String body = "{\"questionnaires\":[{\"questionnaireTitle\":\"这里是问卷标题\",\"channelId\":10002,\"userTags\":[\"vip\",\"registered\"],\"autoPublishTime\":\"2025-04-31 08:00\",\"autoEndTime\":\"2025-04-31 08:30\",\"questions\":[{\"name\":\"题目名称qwe1\",\"type\":\"R\",\"answer\":\"A\",\"required\":\"Y\",\"options\":[\"选项1\",\"选项2\",\"选项3\"]}]},{\"questionnaireTitle\":\"这里是问卷标题2\",\"channelId\":10003,\"questions\":[{\"name\":\"题目名称qwe2\",\"type\":\"R\",\"answer\":\"B\",\"required\":\"Y\",\"scoreEnabled\":\"Y\",\"score\":10,\"options\":[\"选项1\",\"选项2\",\"选项3\"]}]}]}";
    requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
    String url = HttpUtil.appendUrl(temp,requestMap);
    String response = HttpUtil.postJsonBody(url, body, null);
    log.info("测试批量创建问卷接口返回值:{}",response);
    //do somethings
}

响应示例

系统全局错误说明详见全局错误说明

成功示例

{
  "code": 200,
  "status": "success",
  "requestId": "ed721ebb-9add-4469-ad0f-e46db8aac206",
  "data": {
    "questionnaires": [
      {
        "channelId": 10002,
        "questionnaireId": "h6mmyaxze1",
        "questionIds": ["feqfr13ftz"]
      },
      {
        "channelId": 10003,
        "questionnaireId": "h6mmyaxze2",
        "questionIds": ["feqfr13ft1"]
      }
    ]
  },
  "success": true
}

异常示例

{
    "code": 400,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
联系客服,在线咨询