09-21-2022 08:13 AM
09-21-2022 11:52 AM
Are you sending the attachment using a URL or sending as a local file upload?
09-21-2022 12:00 PM
09-21-2022 12:00 PM
Local file upload
09-21-2022 12:47 PM
That should work and this is a curl example where the .jpg file did render the preview correctly.
curl --location --request POST 'https://webexapis.com/v1/messages' \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--form 'files=@"/Users/jeffmar/Downloads/Sample_Icon.jpg"' \
--form 'markdown="File sent using curl"' \
--form 'toPersonEmail="user@example.com"'
10-06-2022 02:31 AM
I'm having a similar issue working in Powershell, the image does send but no preview. Any suggestions?
$uri = "https://api.ciscospark.com/v1/messages"
$filePath = "C:\Users\Harry\Documents\WebexTestImage.png"
$file = Get-Item -Path $filePath
$form = @{
toPersonEmail = "MYEMAIL"
markdown = "TestImage"
files = $file
}
$params = @{
Method = "Post"
Uri = $uri
Form = $form
Headers = @{"Authorization"="Bearer $Ciscobottoken"}
}
Invoke-WebRequest @params
10-06-2022 12:46 PM - edited 10-06-2022 12:47 PM
Running this request and looking at the raw HTTP, it looks like the Content-Type of the file part is set to "application/octet-stream" (i.e. a default/non-descript binary file type), whereas I suspect Webex is expecting this to be "image/png" if you want PNG image preview treatments.
The Curl and Python samples in the Webex docs re Message Attachments seem to indicate indicating the mime-type specifically like this is expected.
A bit of research didn't turn up a way to set a custom Content-Type for sub-parts using the PowerShell IWK -Form mechanism you're using. If that's not possible, may need to construct the message using more "manual"/specific mechanisms, e.g.: https://get-powershellblog.blogspot.com/2017/09/multipartform-data-support-for-invoke.html
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide