Graph API attachment not accepting ContentBytes

Akash Sharma 1 Reputation point
2021-08-25T04:03:48.28+00:00

While using microsoft.graph for .net version 4.3
I am encountering the error that microsoft.graph.attachment does not accept property
ContentBytes or Odata or Additional Data

Can you guys help me resolve this issue i am trying to add an attachment with the mail
Creating a reply
Adding the attachment
Sending mail
Above are the steps i am following.

126089-20210825-092829.jpg

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Diana Wanjuhi 1,376 Reputation points
    2021-09-15T14:08:51.47+00:00

    Hello @Akash Sharma Thank you for reaching out. This is happening because the resource type is wrong, the attachment in this case is of type "@odata.type": "#microsoft.graph.fileAttachment" see documentation here: fileattachment

    The microsoft.graph.attachment looks like this: attachment

    {  
      "contentType": "string",  
      "id": "string (identifier)",  
      "isInline": true,  
      "lastModifiedDateTime": "String (timestamp)",  
      "name": "string",  
      "size": 1024  
    }  
    

    To fix this issue, ensure the type is correct.

    Let me know whether this helps, and if you have further questions.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.