用的帮助文档里的示例的代码,
但是总是提示某某参数无效,而且这些参数都是可选参数
而我把传递参数换成技能对话文档里的那串参数却没问题
JObject job = JObject.Parse(getAccessToken());
string token = job["access_token"].ToString();
string host = "https://aip.baidubce.com/rpc/2.0/unit/bot/chat?access_token=" + token;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(host);
request.Method = "post";
request.ContentType = "application/json";
request.KeepAlive = true;
//string str = "{\"log_id\":\"UNITTEST_10000\",\"version\":\"2.0\",\"service_id\":\"S10550\",\"session_id\":\"\",\"request\":{\"query\":\"你好\",\"user_id\":\"88888\"},\"dialog_state\":{\"contexts\":{\"SYS_REMEMBERED_SKILLS\":[\"21441\",\"21443\"]}}}"; // json格式
string str= "{\"bot_session\":\"\",\"log_id\":\"7758521\",\"request\":{\"bernard_level\":0,\"client_session\":\"{\\\"client_results\\\":\\\"\\\", \\\"candidate_options\\\":[]}\",\"query\":\"你好\",\"query_info\":{\"asr_candidates\":[],\"source\":\"KEYBOARD\",\"type\":\"TEXT\"},\"updates\":\"\",\"user_id\":\"88888\"},\"bot_id\":\"21441\",\"version\":\"2.0\"}"; // json格式
byte[] buffer = Encoding.UTF8.GetBytes(str);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
string result = reader.ReadToEnd();
Console.WriteLine("对话接口返回:");
Console.WriteLine(result);
return result;
机器人对话接口地址与技能对话的接口地址不同,请确认一下调用机器人对话的地址是否写错了
机器人接口地址
https://aip.baidubce.com/rpc/2.0/unit/service/chat
机器人对话接口地址与技能对话的接口地址不同,请确认一下调用机器人对话的地址是否写错了
机器人接口地址
https://aip.baidubce.com/rpc/2.0/unit/service/chat