2016-08-25 95 views
0

我正嘗試使用office365 REST API爲郵件對象創建ItemAttachment。我無法打開POST API,因爲有三個必需的身體參數,我無法找到發送第三個必需參數的方法,即「Item」。請查找the documentation。在這個鏈接中,提到給Item或Event實體作爲'Item'的值。我需要與兩個實體合作。我正在尋找一種方法來表示這個特定領域的價值。 以下是我已經嘗試過:我無法使用office365 REST API創建郵件對象的ItemAttachment

"Item":{ 
"Message": { 
"Subject": "Can we meet for lunch?", 
"Body": { 
    "ContentType": "Text", 
    "Content": "The new cafeteria is open." 
}, 
"ToRecipients": [ 
    { 
    "EmailAddress": { 
     "Address": "[email protected]" 
    } 
    } 
], 
"Attachments": [ 
    { 
    "@odata.type": "#Microsoft.OutlookServices.ItemAttachment", 
    "Name": "menu.txt", 
    "Item":[{"abcd":"pqrs"}] 
    } 
] 

}}

我得到了多個錯誤的各種試驗。 我覺得以下錯誤消息可能會有所幫助:

{ 「錯誤」:{ 「代碼」:「RequestBodyRead」, 「消息」:「從讀書時意外‘PrimitiveValue’節點發現JSON閱讀器,預計'StartObject'節點。「 } }

回答

0

一個有效 JSON有效載荷,用於創建與項附件(Message實體)的消息應該是這樣的:

{ 
    "Attachments": [{ 
     "Item": { 
      "Body": { 
       "ContentType": "Text", 
       "Content": "--Content goes here--", 
       "@odata.type": "#Microsoft.OutlookServices.ItemBody", 
       "[email protected]": "#Microsoft.OutlookServices.BodyType" 
      }, 
      "Subject": "--test--", 
      "ToRecipients": [{ 
       "EmailAddress": { 
        "Name": "Jon Doe", 
        "Address": "[email protected]" 
       } 
      }], 
      "@odata.type": "#Microsoft.OutlookServices.Message" 
     }, 
     "ContentType": "message\rfc822", 
     "IsInline": false, 
     "Name": "--test--", 
     "@odata.type": "#Microsoft.OutlookServices.ItemAttachment" 
    }], 
    "Body": { 
     "ContentType": "Text", 
     "Content": "--Content goes here--", 
     "@odata.type": "#Microsoft.OutlookServices.ItemBody", 
     "[email protected]": "#Microsoft.OutlookServices.BodyType" 
    }, 
    "Subject": "--test--(with message attachment)", 
    "ToRecipients": [{ 
     "EmailAddress": { 
      "Name": "Jon Doe", 
      "Address": "[email protected]" 
     } 
    }] 
} 
+0

在給出的例子您提供一個完全新的消息附加到作爲項目附件創建的消息。但是,我怎樣才能將一個事件或消息作爲一個項目附件添加到消息中呢?這可能嗎?如果是的話,那麼該怎麼做呢? –

相關問題