Office 365 REST API (Python) Mark Email As Read

I am sure that I am doing something simple, but I canโ€™t understand for life how to set the IsRead property to true. This is the last step of my process, which receives a filtered list of messages and stores and processes any attachments.

According to the docs, "IsRead" is writable: http://msdn.microsoft.com/office%5Coffice365%5CAPi/complex-types-for-mail-contacts-calendar#ResourcesMessage

http://msdn.microsoft.com/office%5Coffice365%5CAPi/mail-rest-operations#MessageoperationsUpdatemessages

I am using python 2.7 and the query module:

# once file acquired mark the email as read
params = {'IsRead':'True'}
base_email_url = u'https://outlook.office365.com/api/v1.0/me/messages/{0}'.format( msgId )
response = requests.patch(base_email_url, params, auth=(email,pwd))
log.debug( response )

The answer that is returned is as follows:

{"error":{"code":"ErrorInvalidRequest","message":"Cannot read the request body."}}

What is the problem with my request?

+4
2

. , Content-Type "application/json" - . , :

PATCH https://outlook.office365.com/api/v1.0/Me/Messages('msgid') HTTP/1.1
Accept: application/json;odata.metadata=full
Authorization: Bearer <token>
Content-Type: application/json;odata.metadata=full
Host: outlook.office365.com
Content-Length: 24
Expect: 100-continue
Connection: Keep-Alive

{
  "IsRead": "true"
}
+1

, , . , PATCH GET POST. , , .

:

# once file acquired mark the email as read
changes = {u'IsRead':u'True'}
headers = {'Content-Type': 'application/json'}
json_changes = json.dumps(changes)
base_email_url = u'https://outlook.office365.com/api/v1.0/me/messages/{0}'.format( msgId )
response = requests.patch(base_email_url, data=json_changes, auth=__AUTH, headers=headers)
log.debug( response )
+1

All Articles