Closed rafaltrzcinski closed 6 years ago
Could you include the JSON request body as well?
Probably i see where problem is: in JSON request body field @odata.type
is missing, but actually i set it by FileAttachment().oDataType = "microsoft.graph.fileAttachment"
(or with #
at the begging) so the request body looks like:
{
"contentBytes":"base64 file content",
"contentId":"some_id",
"isInline":false,
"name":"file.jpg"
}
when i send it by raw JSON with @odata.type
it is created correctly - why setting oDataType
to FileAttachment
won't add @odata.type
in request body?
OK, this is what I suspected. You are correct - the bug here is that there is a rule in the serializer to ignore @odata.type because it is a transient type. I will check in a fix shortly
@cbales thank you for quick response 💪 Is there way to put file attachment into message in the same POST that create draft/send message?
You're welcome; you lucked out as someone had reported the bug internally a few days ago and I had just fixed it and was getting ready to make the commit! Unfortunately, you cannot put the attachment in the same POST request. This would require you to POST a new collection page to the draft, which isn't a scenario supported by the SDK. This is why the sample doesn't simply use the SendMail endpoint, which would prevent needing to create a draft in the first place.
Trying to follow example of adding file attachment for created draft message. Getting the error: 422 : Unprocessable Entity
Attachment is created the same way as in code example, by
FileAttachment
object, all fields are filled the same way. Is there another way to send file attachment in the same POST where draft message is created?