Polyv Help Center

Help Center

Add or Modify Channel Questionnaire

Updated: 2025-04-22 13:59:14

API Description

1、编辑或添加问卷信息,为全量增加或修改
2、(channelId, timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议

API URL

http://api.polyv.net/live/v3/channel/questionnaire/add-edit-questionnaire

Online API Call

Request Method

POST

API Constraints

  1. The API supports both HTTP and HTTPS. HTTPS is recommended to ensure API security. API calls have frequency limits. See details

Request Parameter Description

Parameter Required Type Description
appId true String Account appId See details on obtaining keys
timestamp true Long Current 13-digit millisecond timestamp, valid within 3 minutes
sign true String Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must not be stored or used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See signature generation rules
channelId true String Channel ID

Request Body Parameter Description

Parameter Required Type Description
questionnaireTitle true String Questionnaire title
questions true Array Question array See questions field description
questionnaireId false String Questionnaire ID, required when modifying a questionnaire
customQuestionnaireId false String Custom questionnaire ID
autoPublishTime false String Scheduled auto-publish time for the questionnaire (format: "yyyy-MM-dd HH:mm"; must be at least 1 minute later than current time; required when autoEndTime is provided)
autoEndTime false String Scheduled auto-end time for the questionnaire (format: "yyyy-MM-dd HH:mm"; must be later than autoPublishTime; required when autoPublishTime is provided)

Questions Field Description

Parameter Required Type Description
questionId false String Question ID, required when modifying a questionnaire
name true String Question text
type true String Question type
R: Single choice
C: Multiple choice
Q: Q&A
scoreEnabled false String Whether scoring is enabled for the question
Y: Enabled
N: Disabled
answer false String Required for scored multiple-choice questions; provide the corresponding option index, e.g., A or AB
required false String Whether the question is mandatory
Y: Mandatory
N: Optional
options false String[] Required for single-choice or multiple-choice questions; option array indices 0-9 correspond to answers A-J

Example

https://api.polyv.net/live/v3/channel/questionnaire/add-edit-questionnaire?appId=frlr1zazn3&sign=439CDA1327558DFCF947F305D03AFA92&channelId=1965681&timestamp=1621843779393

Request Body Parameters

{
    "questionnaireId": "fwnf2sbpf5",
    "customQuestionnaireId": "6a3ff44289f94a5fb1dd8341ac1c0100",
    "questionnaireTitle": "这里是问卷标题",
    "questions": [{
        "questionId": "feqfr13ftz",
        "name": "题目名称qwe",
        "type": "R",
        "answer": "A",
        "scoreEnabled": "Y",
        "score": 10,
        "required": "Y",
        "options": ["选项1", "选项2", "选项3"]
    }]
}

Response Parameter Description

Parameter Type Description
code Integer Response status code, 200 for success, non-200 for failure See global error description
status String Response status text
message String Response description, provides error details when code is 400 or 500
data Object Basic questionnaire information on success See data field description

Data Field Description

Parameter Type Description
questionnaireId String Questionnaire ID
questionIds String[] Question array
questionnaireTitle String Questionnaire title

Java Request Example

For quick integration of basic code, download the relevant dependency source code. Click to download source code. After downloading, add it to your own source code project. The HttpUtil.java and LiveSignUtil.java in the test cases are included in the download file.

It is strongly recommended to use the Live Java SDK for API integration. The Live Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.

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 channelId = "1965681";
    String temp = "https://api.polyv.net/live/v3/channel/questionnaire/add-edit-questionnaire";

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

    requestMap.put("channelId",channelId);

    String body = "{\"questionnaireId\":\"fwnf2sbpf5\",\"customQuestionnaireId\":\"6a3ff44289f94a5fb1dd8341ac1c0100\",\"questionnaireTitle\":\"这里是问卷标题\",\"questions\":[{\"questionId\":\"feqfr13ftz\",\"name\":\"题目名称qwe\",\"type\":\"R\",\"answer\":\"A\",\"scoreEnabled\":\"Y\",\"score\":10,\"required\":\"Y\",\"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
}

Response Example

For global system error descriptions, see Global Error Description

Success Example

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
        "questionnaireId": "fwnf2sbpf5",
        "questionIds": ["feqfr13ftz"],
        "questionnaireTitle": "这里是问卷标题"
    }
}

Error Example

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