ボットに送信された添付ファイルをあるユーザーから別のユーザーにルーティングしようとしています。私はエミュレータからエミュレータ/テレグラム/スカイプに何かを送ろうとしている間にうまく動作しますが、スカイプ/テレグラムから送信しようとすると全く動作しません(スカイプは何も言わない、テレグラムは次のように主張しています: "POST to mybotが失敗しました:HTTPステータス500 "でボットのエンドポイントへのPOSTが失敗しました。どこで問題を見つけようとすべきですか?添付ファイルのルーティング
if (mes.Attachments != null && mes.Attachments.Any())
{
var list = new List<Attachment>();
foreach (var attachment in mes.Attachments)
{
using (HttpClient httpClient = new HttpClient())
{
// Skype attachment URLs are secured by a JwtToken, so we need to pass the token from our bot.
if (mes.ChannelId.Equals("skype", StringComparison.InvariantCultureIgnoreCase) &&
new Uri(attachment.ContentUrl).Host.EndsWith("skype.com"))
{
var mstoken = await new MicrosoftAppCredentials().GetTokenAsync();
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer",
mstoken);
}
var responseMessage = await httpClient.GetAsync(attachment.ContentUrl);
var ms = await ConvertContentToByteArray(responseMessage);
var sendAttachment = new Attachment()
{
ContentType = attachment.ContentType,
Name = attachment.Name,
ContentUrl = String.Format("data:image/png;base64,{1}", attachment.ContentType,
Convert.ToBase64String(ms))
};
list.Add(sendAttachment);
}
}
message.Attachments = list;
message.AttachmentLayout = mes.AttachmentLayout;
}
await connector.Conversations.SendToConversationAsync((Activity)message);
"のMES" の着信メッセージ、「メッセージである - 前記結果
は、あなたの答えを事前にありがとうござい
UPDATE 1:ここ
は私のコードです。I!残念ながら、ファイルサイズ制限の新しい問題が発生しました(Useful post参照)。
私のために有用であったのいくつかのリンク:Send Attachment Sample、Receive Attachment Sample、Useful post、Some other receiving example
エラーメッセージ "HTTPステータス500でボットのエンドポイントへのPOSTが失敗しました"は、ボットが500を投げていることを意味します。デバッガを接続してキャッチできるかどうかを確認してください。 – Lars
あなたの答えをありがとう!私はクラウド内でアプリケーションを直接デバッグすることは可能であることに気づいていませんでした(エミュレータではありません)。 [リモートデバッグWebアプリケーション](https://docs.microsoft.com/en-us/azure/app-service-web/web-sites-dotnet-troubleshoot-visual-studio)のリンク方法はこちらです。また、[この回答](http://stackoverflow.com/questions/17659473/visual-studio-remote-debugger-invalid-access-to-memory-location-feature)のパッチを適用して動作させる必要がありました。 – Sovan