2016-08-25 38 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

在给出的例子您提供一个完全新的消息附加到作为项目附件创建的消息。但是,我怎样才能将一个事件或消息作为一个项目附件添加到消息中呢?这可能吗?如果是的话,那么该怎么做呢? –

相关问题