1

I'm making a request to the Microsoft Graph API to the messages/delta endpoint, and seeing invalid JSON being returned as a result of an ErrorCannotOpenFileAttachment error, which is also causing the @odata.nextLink property to be missing from the response.

Example request:

Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
User-Agent: Ruby
Host: graph.microsoft.com
Authorization: Bearer {some_token}
Prefer: odata.maxpagesize=1
Connection: keep-alive

GET /v1.0/me/mailFolders('{some_folder_id}')/messages/delta?$skiptoken={some_skip_token}

Example response:

HTTP/1.1 200 OK
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8
Content-Encoding: gzip
Strict-Transport-Security: max-age=31536000
request-id: f1cb18ba-cf86-4060-8ad9-82e7c31bb2ec
client-request-id: f1cb18ba-cf86-4060-8ad9-82e7c31bb2ec
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"West US 2","Slice":"E","Ring":"1","ScaleUnit":"001","RoleInstance":"MW2PEPF0000E53D"}}
Date: Thu, 10 Aug 2023 14:10:58 GMT
Connection: keep-alive

{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#Collection(message)","value":[{"error":{"code":"ErrorCannotOpenFileAttachment","message":"The attachment could not be opened."}}

You can see that the JSON response is missing the closing square bracket for the value property and does not include the @odata.nextLink (or @odata.deltaLink) property.

I set the Prefer header to odata.maxpagesize=1 narrow down the response to a single record.

Is there away to ignore this error that appears to be caused by a single, perhaps malformed email or attachment, and continue on to the next page of the delta request? Or is there a way to filter out specific message Ids from the messages/delta request?

It looks like a similar scenario was raised here: Microsoft Graph API - Filter messages response contains invalid JSON

Scott Hill
  • 47
  • 7

0 Answers0