使用 Postman 的 D365 机会笔记附件

D365 Opportunity notes attachments using Postman

我的 JSON 结构需要帮助。我正在尝试附加以下 base64 字符串并绑定 D365 中的现有机会 - 使用 postman

WebApi 请求 :

POST : https://Mydomainurl.crm8.dynamics.com/api/data/v9.1/annotations

{
  "subject": "Test From Web API",
  "filename": "encoded oppjs.txt",
  "opportunity@odata.bind ":"/opportunity(0cff802f-23e1-40b3-aebc-b36b6d8d2e68)",
  "documentbody" : "DQp2YXIgdzMgPSB7fTsNCnczLmhpZGUgPSBmdW5jdGlvbiAoc2VsKSB7DQogIHczLmhpZGVFbGVtZW50cyh3My5nZXRFbGVtZW50cyhzZWwpKTsNCn07DQp3My5oaWRlRWxlbWVudHMgPSBmdW5jdGlvbiAoZWxlbWVudHMpIHsNCiAgdmFyIGksIGwgPSBlbGVtZW50cy5sZW5ndGg7DQogIGZvciAoaSA9IDA7IGkgPCBsOyBpKyspIHsNCiAgICB3My5oaWRlRWxlbWVudChlbGVtZW50c1tpXSk7DQogIH0NCn07DQp3My5oaWRlRWxlbWVudCA9IGZ1bmN0aW9uIChlbGVtZW50KSB7DQogIHczLnN0eWxlRWxlbWVudChlbGVtZW50LCAiZGlzcGxheSIsICJub25lIik7DQp9Ow0KdzMuc2hvdyA9IGZ1bmN0aW9uIChzZWwsIGEpIHsNCiAgdmFyIGVsZW1lbnRzID0gdzMuZ2V0RWxlbWVudHMoc2VsKTsNCiAgaWYgKGEpIHt3My5oaWRlRWxlbWVudHMoZWxlbWVudHMpO30NCiAgdzMuc2hvd0VsZW1lbnRzKGVsZW1lbnRzKTsNCn07DQp3My5zaG93RWxlbWVudHMgPSBmdW5jdGlvbiAoZWxlbWVudHMpIHsNCiAgdmFyIGksIGwgPSBlbGVtZW50cy5sZW5ndGg7DQogIGZvciAoaSA9IDA7IGkgPCBsOyBpKyspIHsNCiAgICB3My5zaG93RWxlbWVudChlbGVtZW50c1tpXSk7DQogIH0NCn07DQp3My5zaG93RWxlbWVudCA9IGZ1bmN0aW9uIChlbGVtZW50KSB7DQogIHczLnN0eWxlRWxlbWVudChlbGVtZW50LCAiZGlzcGxh"

}

响应: 501 错误请求

在 json 上试试这个: POST : https://Mydomainurl.api.crm8.dynamics.com/api/data/v9.1/annotations 让我知道,你有一些错误,请注意 odata.bind 以及它如何绑定到 D365 中你想要 link 的机会,并且你在粘贴的示例中遇到了一些间距问题嗯:

{
    "subject": "Test From Web API", 
    "filename": "encoded oppjs.txt", 
    "isdocument" : true,
    "objectid_opportunity@odata.bind": "opportunities(0cff802f-23e1-40b3-aebc-b36b6d8d2e68)", 
"documentbody":"DQp2YXIgdzMgPSB7fTsNCnczLmhpZGUgPSBmdW5jdGlvbiAoc2VsKSB7DQogIHczLmhpZGVFbGVt ZW50cyh3My5nZXRFbGVtZW50cyhzZWwpKTsNCn07DQp3My5oaWRlRWxlbWVudHMgPSBmdW5jdGlv biAoZWxlbWVudHMpIHsNCiAgdmFyIGksIGwgPSBlbGVtZW50cy5sZW5ndGg7DQogIGZvciAoaSA9IDA7IGkgPCBsOyBpKyspIHsNCiAgICB3My5oaWRlRWxlbWVudChlbGVtZW50c1tpXSk7DQogIH0N Cn07DQp3My5oaWRlRWxlbWVudCA9IGZ1bmN0aW9uIChlbGVtZW50KSB7DQogIHczLnN0eWxlRWxlbWVudChlbGVtZW50LCAiZGlzcGxheSIsICJub25lIik7DQp9Ow0KdzMuc2hvdyA9IGZ1bmN0aW9u IChzZWwsIGEpIHsNCiAgdmFyIGVsZW1lbnRzID0gdzMuZ2V0RWxlbWVudHMoc2VsKTsNCiAgaWYgKGEpIHt3My5oaWRlRWxlbWVudHMoZWxlbWVudHMpO30NCiAgdzMuc2hvd0VsZW1lbnRzKGVsZW1l bnRzKTsNCn07DQp3My5zaG93RWxlbWVudHMgPSBmdW5jdGlvbiAoZWxlbWVudHMpIHsNCiAgdmFyIGksIGwgPSBlbGVtZW50cy5sZW5ndGg7DQogIGZvciAoaSA9IDA7IGkgPCBsOyBpKyspIHsNCiAg ICB3My5zaG93RWxlbWVudChlbGVtZW50c1tpXSk7DQogIH0NCn07DQp3My5zaG93RWxlbWVudCA9IGZ1bmN0aW9uIChlbGVtZW50KSB7DQogIHczLnN0eWxlRWxlbWVudChlbGVtZW50LCAiZGlzcGxh" 
}