Error Creating Outlook Rule with Graph API when using conditions fromAddresses

Mario Zamora 20 Reputation points
2023-09-26T21:58:31.5066667+00:00

When creating a rule in which a condition of email coming from a specified sender, the following error message is generated by the Graph API:

Status code: 400, Response: {"error":{"code":"UnableToDeserializePostBody","message":"were unable to deserialize "}}

The following payload was sent to the Microsoft Graph API:

Endpoint:

https://graph.microsoft.com/v1.0/users/{user_email}/mailFolders/inbox/messageRules
{ 
        "displayName": "Supervisor Manager Tag",
        "sequence": 1,
        "isEnabled": "true",
        "conditions": {"fromAddresses": [{"emailAddress": {"name": "The Boss", "address": "boss@organization.com"}}]},
        "actions": {
            "flag": {
                "flagStatus": "flagged",
                "flagColor": "#FF0000"
            },
            "assignCategories": ["Blue category"]
        }
    
    }
Outlook
Outlook
A family of Microsoft email and calendar products.
3,700 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,829 questions
0 comments No comments
{count} votes

Accepted answer
  1. Glen Scales 4,436 Reputation points
    2023-09-27T01:03:29.93+00:00

    The Graph Inbox rule endpoint only provides a subset of the full rules action that you can do in either the Outlook desktop client or Outlook on the web. So in your example using

                "flag": {
                    "flagStatus": "flagged",
                    "flagColor": "#FF0000"
                },
    

    the flag action isn't available in the Graph API in v1.0 or beta the documentation list the available actions https://learn.microsoft.com/en-us/graph/api/resources/messageruleactions?view=graph-rest-1.0 or if you check it MessageruleActions in the metadata eg

    <ComplexType Name="messageRuleActions">
    <Property Name="assignCategories" Type="Collection(Edm.String)"/>
    <Property Name="copyToFolder" Type="Edm.String"/>
    <Property Name="delete" Type="Edm.Boolean"/>
    <Property Name="forwardAsAttachmentTo" Type="Collection(graph.recipient)"/>
    <Property Name="forwardTo" Type="Collection(graph.recipient)"/>
    <Property Name="markAsRead" Type="Edm.Boolean"/>
    <Property Name="markImportance" Type="graph.importance"/>
    <Property Name="moveToFolder" Type="Edm.String"/>
    <Property Name="permanentDelete" Type="Edm.Boolean"/>
    <Property Name="redirectTo" Type="Collection(graph.recipient)"/>
    <Property Name="stopProcessingRules" Type="Edm.Boolean"/>
    </ComplexType>
    
    

    EWS also doesn't support that action https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/actions . The only Exchange API that does would be Mapi through the Tag action https://www.dimastr.com/redemption/rdo/rdoruleaction.htm#RDORuleActionTag

    Otherwise look at subscriptions and build an app to modify the item.

    2 people found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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