Error 405: 'The OData request is not supported.' when using python requests library. What's going on?

William Drakon 6 Reputation points
Content-type: application/json
Request Body:
    "message": {
        "subject": "Subject",
        "body": {
            "contentType": "HTML",
            "content": "<p>Body</p>"
        "toRecipients": [
                "emailAddress": {
                    "address": ""
        "attachments": [
                "@odata.type": "#microsoft.graph.fileAttachment",
                "name": "filename.pdf",
                "contentType": "application/pdf",
                "contentBytes": "JVBERi0x..."

This 405 error is generated when using the requests library in python:

{'error': {'code': 'ErrorInvalidRequest', 'message': 'The OData request is not supported.'}}

When the identical JSON body is used in the Graph Explorer tool, the response is Accepted - 202.

Identical scopes in either context, the only difference is using requests vs. Graph Explorer. All aspects of the email are correct when sent via Graph Explorer, and other posts/gets have worked when using the requests library. Just not sure what's going on.

Microsoft Graph Mail API
Microsoft Graph Mail API
A Microsoft API that supports accessing data in users' primary mailboxes and in shared mailboxes.
682 questions
No comments
1 vote

1 answer

Sort by: Most helpful
  1. William Drakon 6 Reputation points

    I've since determined that when using python, I was inadvertently using the url, not, hence a problem. Long story short, small mistake that I didn't catch at first. Things are working as intended now.

    No comments