405: 'The OData request is not supported.' When creating reply in outlook using MS_graph

Viewed 24

I want to create a draft message which replies to a message. I have got the message id, however, when creating the reply I get an error:

async def create_reply(self, werknemer, message_id, body):
    '''Create a reply to a message'''
    
    url = self.base_url +  f'Users/{user}@{domain}.onmicrosoft.com/messages/{message_id}/createReply' 
    
    payload = {
    'importance': 'high',  
    'body': {
        "ContentType": "HTML",
        "Content": body
    }
}
    
    headers = self.auth_header
    headers['Content-Type'] = 'application/json'
    
    async with (
        aiohttp.ClientSession(**self.client_args) as s,
        s.post(url, headers=self.auth_header, data=json.dumps(payload)) as r,
    ):       
       
        print(r.status)
        print(r.reason)
            
        r = await r.json()
        pprint(r)
405
Method Not Allowed
{'error': {'code': 'ErrorInvalidRequest',
           'message': 'The OData request is not supported.'}}

I tried using patch instead of post. This succeeds, but this edited the original message instead of creating a new draft.

How

0 Answers
Related