Azure / Microsoft365R

R SDK for interacting with Microsoft 365 APIs
Other
313 stars 44 forks source link

Bad Request (HTTP 400) error when attaching .xlsx file to Teams Chat #73

Closed zekePhoenix closed 3 years ago

zekePhoenix commented 3 years ago

I'm trying to add an excel file to a channel chat. I have no isses attaching a PDF. But I'm getting this error when I attempt to attach either a xlsx or csv file. Error in process_response(res, match.arg(http_status_handler), simplify) : Bad Request (HTTP 400). Failed to complete operation. Message: File contentUrl extension: '.xlsx&action=default&mobileredirect=true' and name extension: '.xlsx' do not match.

Here is the code for attaching the PDF. This works as expected. chan$send_message(paste0("Here is the Daily COBRA report for ",format(date_today,"%m-%d-%Y")), attachments = "C:\\RTasks\\DailyCOBRAEmail\\Test PDF.pdf")

I get the error when adding in an xlsx file. chan$send_message(paste0("Here is the Daily COBRA report for ",format(date_today,"%m-%d-%Y")), attachments = c("C:\\RTasks\\DailyCOBRAEmail\\Test PDF.pdf","C:\\RTasks\\DailyCOBRAEmail\\Book99.xlsx"))

Thanks.

hongooi73 commented 3 years ago

Does it work if you attach only the xlsx file?

zekePhoenix commented 3 years ago

Yes. Same error when only attaching the xlsx file. chan$send_message(paste0("Here is the Daily COBRA report for ",format(date_today,"%m-%d-%Y")), attachments = "C:\\RTasks\\DailyCOBRAEmail\\Book99.xlsx")

Error in process_response(res, match.arg(http_status_handler), simplify) : Bad Request (HTTP 400). Failed to complete operation. Message: File contentUrl extension: '.xlsx&action=default&mobileredirect=true' and name extension: '.xlsx' do not match.

hongooi73 commented 3 years ago

Ugh, Microsoft making life difficult....

zekePhoenix commented 3 years ago

It figures Microsoft would make it difficult. Are you able to replicate the issue? I had the same issue with csv file. But not with a docx file. 🤷

hongooi73 commented 3 years ago

I have a fix in the parent-item branch. Can you let me know if it works?

zekePhoenix commented 3 years ago

Yes. It works now. For both xlsx files and csv files. Thanks.