5

We have a function set up to send emails via Outlook from our web app and it's been working great, but suddenly this morning my email inbox is flooded with errors from our system saying it couldn't send the email with outlook because of a bad request. The errors all look like this:

{"error":{"code":"BadRequest","message":"Invalid OData type specified: \"Microsoft.OutlookServices.FileAttachment\"","innerError":{"date":"2021-07-02T05:43:00","request-id":"XXX","client-request-id":"XXX"}}}

As I say it was working yesterday, but now it's not. And a lot of these don't have specific attachments outside of the embedded header image, which has not been changed since it was working.

Any suggestions on reasons for the error?

user1770717
  • 309
  • 1
  • 12

1 Answers1

9

OK so I figured this out. For some reason our attachments were still set as '#Microsoft.OutlookServices.FileAttachment' for the data type. I changed this to 'microsoft.graph.fileAttachment' and it is now working again. I don't know why it decided to force a change over today, but I'll leave this question and answer up in case someone else has the same problem.

user1770717
  • 309
  • 1
  • 12
  • 1
    Experienced the same thing this morning, and your suggested fix worked for me. Will have to follow up with Microsoft to hear why this was changed today! – pypmannetjies Jul 02 '21 at 12:27
  • Started seeing the same problem. Thanks for posting this, it helped debug much faster. – Pratik Bhattacharya Jul 03 '21 at 14:11
  • I had a similar error trying with the `odata.type: "Microsoft.DirectoryServices.OAuth2PermissionGrant"`, I just change it to `"odata.type": "Microsoft.Graph.OAuth2PermissionGrant",` and now it works. I think it is due to [the migration towards Graph Api](https://techcommunity.microsoft.com/t5/azure-active-directory-identity/update-your-applications-to-use-microsoft-authentication-library/ba-p/1257363) for some Azure resources/endpoints And indeed, [here](https://learn.microsoft.com/en-us/graph/traverse-the-graph#call-actions-and-functions) explain the `odata.type` for your case – bgarcial Aug 12 '21 at 08:57