How to retrieve contents of an itemAttachment via the Microsoft Graph API

前端 未结 2 977
轮回少年
轮回少年 2020-12-11 05:02

I\'m currently developing a solution which is retrieving e-mails via the Microsoft Graph API. In november 2015 Microsoft stated it is ready for production and I\'ve read in

2条回答
  •  无人及你
    2020-12-11 05:30

    Use $expand option:

    GET https://graph.microsoft.com/v1.0/me/messages('AAMkADA1M-zAAA=')/attachments('AAMkADA1M-CJKtzmnlcqVgqI=')/?$expand=microsoft.graph.itemattachment/item 
    

    Response:

    HTTP/1.1 200 OK
    Content-type: application/json
    
    {
      "@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('d1a2fae9-db66-4cc9-8133-2184c77af1b8')/messages('AAMkADA1M-zAAA%3D')/attachments/$entity",
      "@odata.type":"#microsoft.graph.itemAttachment",
      "id":"AAMkADA1MCJKtzmnlcqVgqI=",
      "lastModifiedDateTime":"2017-07-21T00:20:34Z",
      "name":"Reminder - please bring laptop",
      "contentType":null,
      "size":32005,
      "isInline":false,
      "item@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('d1a2fae9-db66-4cc9-8133-2184c77af1b8')/messages('AAMkADA1M-zAAA%3D')/attachments('AAMkADA1M-CJKtzmnlcqVgqI%3D')/microsoft.graph.itemAttachment/item/$entity",
      "item":{
        "@odata.type":"#microsoft.graph.message",
        "id":"",
        "createdDateTime":"2017-07-21T00:20:41Z",
        "lastModifiedDateTime":"2017-07-21T00:20:34Z",
        "receivedDateTime":"2017-07-21T00:19:55Z",
        "sentDateTime":"2017-07-21T00:19:52Z",
        "hasAttachments":false,
        "internetMessageId":"",
        "subject":"Reminder - please bring laptop",
        "importance":"normal",
        "conversationId":"AAQkADA1MzMyOGI4LTlkZDctNDkzYy05M2RiLTdiN2E1NDE3MTRkOQAQAMG_NSCMBqdKrLa2EmR-lO0=",
        "isDeliveryReceiptRequested":false,
        "isReadReceiptRequested":false,
        "isRead":false,
        "isDraft":false,
        "webLink":"https://outlook.office365.com/owa/?ItemID=AAMkADA1M3MTRkOQAAAA%3D%3D&exvsurl=1&viewmodel=ReadMessageItem",
        "body":{
          "contentType":"html",
          "content":"\r\n\r\n\r\n\r\n"
        },
        "sender":{
          "emailAddress":{
            "name":"Adele Vance",
            "address":"AdeleV@contoso.onmicrosoft.com"
          }
        },
        "from":{
          "emailAddress":{
            "name":"Adele Vance",
            "address":"AdeleV@contoso.onmicrosoft.com"
          }
        },
        "toRecipients":[
          {
            "emailAddress":{
              "name":"Alex Wilbur",
              "address":"AlexW@contoso.onmicrosoft.com"
            }
          }
        ],
        "ccRecipients":[
          {
            "emailAddress":{
              "name":"Adele Vance",
              "address":"AdeleV@contoso.onmicrosoft.com"
            }
          }
        ]
      }
    }
    

    Source: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/attachment_get#request-2

提交回复
热议问题