对话机器人服务 CBS-问答满意评价:请求示例

时间:2024-04-07 15:57:32

请求示例

  • 对智能问答返回结果的满意度评价为满意
    POST https://{endpoint}/v1/1604d8170cd84440a81281e5a3a04f8b/qabots/303a0a00-c88a-43e3-aa2f-d5b8b9832b02/requests/303a0a00-c88a/satisfaction
    
    Request Header:
        Content-Type: application/json
        X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...
    
    Request Body:
    {
        "degree":1
    }
  • Python语言请求代码示例
    import requests
    url = "https://{endpoint}/v1/{project_id}/qabots/{qabot_id}/requests/{request_id}/satisfaction"
    body = {"degree":1}
    token = "用户获取得到的实际token值"
    headers = {'Content-Type': 'application/json', 'X-Auth-Token': token}
    
    response = requests.post(url, headers=headers, json=body, verify=False)
    print(response.text)
  • Java语言请求代码示例
    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.net.HttpURLConnection;
    import java.net.URL;
    
    public class CBSDemo {
    
        public void cbsDemo() {
            try {
                //endpoint、projectId、qabot_id需要替换成实际信息。
                URL url = new URL("https://{endpoint}/v1/{project_id}/qabots/{qabot_id}/requests/{request_id}/satisfaction");
                String token = "用户获取得到的实际token值";
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                connection.setRequestMethod("POST");
                connection.setDoInput(true);
                connection.setDoOutput(true);
                connection.addRequestProperty("Content-Type", "application/json");
                connection.addRequestProperty("X-Auth-Token", token);
    
                //输入参数
                String body = "{\"degree\":1}";
    
                OutputStreamWriter osw = new OutputStreamWriter(connection.getOutputStream(), "UTF-8");
                osw.append(body);
                osw.flush();
                InputStream is = connection.getInputStream();
                BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
                while (br.ready()) {
                    System.out.println(br.readLine());
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        public static void main(String[] args) {
            CBSDemo CBSDemo = new CBSDemo();
            CBSDemo.cbsDemo();
        }
    }
support.huaweicloud.com/api-cbs/cbs_03_0073.html