Sending images to facebook causing Microsoft.Rest.HttpOperationException: You must provide an original or thumbnail property
Bot Info
- Bot handle: spjaebot
- App ID: 9c0072eb-f501-4042-af87-353a7dc8aee9
- SDK Platform: .NET
- SDK Version: 3.12
- Active Channels: Direct Line, Web, Telegram, Messenger
- Deployment Environment: Azure website
Issue Description
Sending an image as an attachment causes the following error: Microsoft.Rest.HttpOperationException: You must provide an original or thumbnail property
Code Example
reply.Attachments.Add(new Attachment()
{
ContentType = "image/jpeg",
ContentUrl = resp.ImageUrl,
ThumbnailUrl = "https://www.example.com/image.png",
Name = "Image from SERVICE"
});
Expected Behavior
The image should render as per normal. Funnily enough I've had no issies on web chat, direct line and telegram. Although telegram does take a while to send the image (up to 10s at times) it still does go through.
Actual Results
The client sees the following error sent as a chat message in lieu of the image:

That error message isn't in my code, however. Additionally, this is the stacktrace I see:
Exception thrown: 'Microsoft.Rest.HttpOperationException' in mscorlib.dll
Microsoft.Rest.HttpOperationException: You must provide an original or thumbnail property
at Microsoft.Bot.Connector.ErrorHandling.<HandleErrorAsync>d__2`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Connector.ConversationsExtensions.<ReplyToActivityAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Builder.Dialogs.Internals.AlwaysSendDirect_BotToUser.<Microsoft-Bot-Builder-Dialogs-Internals-IBotToUser-PostAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Builder.Dialogs.Internals.InputHintQueue.<Microsoft-Bot-Builder-Dialogs-Internals-IMessageQueue-QueueMessageAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Builder.Dialogs.Internals.AutoInputHint_BotToUser.<Microsoft-Bot-Builder-Dialogs-Internals-IBotToUser-PostAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Builder.Dialogs.Internals.MapToChannelData_BotToUser.<PostAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Builder.Dialogs.Internals.LogBotToUser.<Microsoft-Bot-Builder-Dialogs-Internals-IBotToUser-PostAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Builder.Dialogs.Internals.PostUnhandledExceptionToUser.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__5.MoveNext()
Exception thrown: 'Microsoft.Rest.HttpOperationException' in Microsoft.Bot.Builder.dll
I do not, however, have these issues on my other deployed channels.
Initially, I did not have a thumbnail URL and neither did I have a have a name parameter. Adding those, however, did not solve my problem. Again, this happens to be one of those bugs that showed up in prod just before Christmas...
Thank you guys for your help!
It may be worth contacting Facebook support on this one @DrWala we'll look into it as well.
Hi guys no ideas from the Msft side?
Hi all,
Is there any update on this? I also encountered this issue and it just started last month in production
It's been spamming "Sorry, my bot code is having an issue"
@fkatada please open a new issue and provide code, thanks
Sending an image will throw an exception if it is not a valid ThumbnailUrl.
This currently works with Messenger:
reply.Attachments.Add(new Attachment()
{
ContentType = "image/jpeg",
ContentUrl = "http://via.placeholder.com/350x150",
ThumbnailUrl = "http://via.placeholder.com/350x150",
Name = "Image from SERVICE"
});
However, VideoCards will throw this exception consistently. I've escalated this to the appropriate team.
Thanks @EricDahlvang, looking forward to a fix :)
Can you attach the ContentUrl for the attachment that you are trying to upload?
Image/video attachments sent to the Facebook channel must contain ContentType and either Content in DataUri format or ContentUrl as a http/https uri. Sending only a ThumbnailUrl is not supported and will return a BadRequest error.
In most cases we pass the ContentUrl directly on to Facebook and if Facebook is unable to load the content an error will be returned. Facebook has limitations on allowable content that will cause errors to be returned on otherwise valid Uri's so that's another thing to check if you are sure you are sending otherwise valid attachments.
If you are still having issues with attachments please include the ContentType and Content/ContentUrl that you are sending and I'd be happy to help investigate the problem.
Hi @craig, I'll pass you an example of the images I'm sending in a few hours and hopefully you can point me in the right direction
Hi,
ok, this is a sample image I have sent: https://res.cloudinary.com/nyx-intelligence/image/upload/sp-route-images/Auditorium and a sample thumbnail is this: https://pbs.twimg.com/profile_images/608090302348271616/_20fw54g.jpg
I was able to send both of those images to Facebook successfully as follows. Note that you must set the image url in the ContentUrl property (ThumbnailUrl is ignored by our Facebook channel).
reply.Attachments.Add(new Attachment()
{
ContentType = "image/png",
ContentUrl = "https://res.cloudinary.com/nyx-intelligence/image/upload/sp-route-images/Auditorium"
});
reply.Attachments.Add(new Attachment()
{
ContentType = "image/jpeg",
ContentUrl = "https://pbs.twimg.com/profile_images/608090302348271616/_20fw54g.jpg"
});
That's weird. It's 1am here I'll test this out again tomorrow. I extracted it from the project i was working on. Funnily enough this issue didn't happen on telegram...
Looks like it works. I guess issue can be closed