我尝试了above method!我收到错误的网关错误。
nuget包 Microsoft.Bot.Connector.DirectLine 3.0.2
uwp-目标版本17134,最低版本16299
var filePath = Path.Combine(ApplicationData.Current.LocalFolder.Path, speechFileName);
using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
using (var client = new HttpClient())
{
var uri = $@"https://directline.botframework.com/v3/directline/conversations/{_conversation.ConversationId}/upload?userId={_fromUser}";
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", DIRECT_LINE_SECRET);
var content = new StreamContent(stream);
content.Headers.ContentType = MediaTypeWithQualityHeaderValue.Parse("audio/wav");
content.Headers.ContentDisposition = new ContentDispositionHeaderValue("file")
{
FileName = "text.wav"
};
var result = await client.PostAsync(uri, content);
if (result != null)
{
}
}
stream.Flush();
}
{StatusCode: 502, ReasonPhrase: 'Bad Gateway', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Server: Microsoft-IIS/10.0
Strict-Transport-Security: max-age=31536000
Cache-Control: no-cache
Date: Tue, 02 Oct 2018 07:27:58 GMT
Pragma: no-cache
Content-Length: 139
Content-Type: application/json; charset=utf-8
Expires: -1
}}
Content: {System.Net.Http.StreamContent}
Headers: {Server: Microsoft-IIS/10.0
Strict-Transport-Security: max-age=31536000
Cache-Control: no-cache
Date: Tue, 02 Oct 2018 07:27:58 GMT
Pragma: no-cache
}
IsSuccessStatusCode: false
ReasonPhrase: "Bad Gateway"
RequestMessage: {Method: POST, RequestUri: 'https://directline.botframework.com/v3/directline/conversations/EDX3Ectf9h93c11LozvGSG/upload?userId=kaki104', Version: 2.0, Content: System.Net.Http.StreamContent, Headers:
{
Authorization: Bearer iMU2qsXQSic.cwA.sjs.DUxL7a5bV-tnpYW79LpLMo8e22Klh8eT6nlGBfQc_FY
Content-Type: audio/wav
Content-Disposition: file; filename=text.wav
Content-Length: 10962
}}
StatusCode: BadGateway
Version: {1.1}
我需要在Bot中添加特殊设置吗?