microsoft-graph-apimicrosoft-graph-mail

Create message in Exchange causes "UnableToDeserializePostBody"


I have some code that was working just fine a few months ago, but something in the Graph API has changed and this no longer works. I am trying to create a message in an existing folder, by doing a POST to this url:

https://graph.microsoft.com/v1.0/users/jjones@transend.onmicrosoft.com/mailFolders/AAMkADNjAAA=/messages

(folder id shortened)

The call fails with http error 400, and the returned error is "UnableToDeserializePostBody". The input json is shown below. By experimentation I was able to trace the problem specifically to "singleValueExtendedProperties". I normally put several properties there, but for this test I removed all but the one you see. I have tried other properties as well, they all fail. This seems like some stupid formatting error but I can't see it. Any help appreciated.

{
"subject": "Test again",
"Sender": {
"emailAddress": {
"name": "John Doe",
"address": "missing@domain.com"
}
},
"body": {
"contentType": "TEXT",
"content": "This is a text message."
},
"toRecipients": [
{
"emailAddress": {
"name": "Jane Smith",
"address": "missing@domain.com"
}
}
],
"ccRecipients": [
{
"emailAddress": {
"name": "Bob Jones",
"address": "missing@domain.com"
}
}
],
"singleValueExtendedProperties": [
{
"propertyId": "SystemTime 0x0039",
"value": "1998-07-29T21:30:00.0000+00:00"
}
],
"importance": "normal"
}


Solution

  • The main problem here is you are specifying the property('propertyid') in singleValueExtendedProperties object is not valid. There are only 2 properties in singleValueExtendedProperties. One is id and the other is value.

    Replace 'propertyId' with id.

    I have tested it in POSTMAN with your payload changing the propertyId to id and it worked.

    enter image description here

    Request Body:-

    {
    "subject": "Test again",
    "Sender": {
    "emailAddress": {
    "name": "John Doe",
    "address": "missing@domain.com"
    }
    },
    "body": {
    "contentType": "TEXT",
    "content": "This is a text message."
    },
    "toRecipients": [
    {
    "emailAddress": {
    "name": "Jane Smith",
    "address": "missing@domain.com"
    }
    }
    ],
    "ccRecipients": [
    {
    "emailAddress": {
    "name": "Bob Jones",
    "address": "missing@domain.com"
    }
    }
    ],
    "singleValueExtendedProperties": [
    {
    "id": "SystemTime 0x0039",
    "value": "1998-07-29T21:30:00.0000+00:00"
    }
    ],
    "importance": "normal"
    }