将附件上传到 Dynamics CRM 时设置相关参考时出现问题
Problems setting related reference while uploading attachments to Dynamics CRM
我在发送附件时遇到了一些问题。它看起来像这样:
{
"filename": "Test.txt",
"subject": "Test",
"mimetype": "text/plain",
"documentbody": "SABlAGwAbABvACAAVwBvAHIAbABkAA==",
"objectid@odata.bind": "/accounts(3ba2f6ab-3849-e811-a83b-000d3a2b2acb)",
"isdocument": true
}
我得到的错误:
"error": {
"code": "0x0",
"message": "An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'objectid' which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values."
知道这里出了什么问题吗?我是不是定义错了注解和账号的关系?
试试下面,您缺少 MimeType,这对于了解附件的类型很重要。刚刚在我的一个系统上试过,它可以工作。
{
"filename": "Test.txt",
"documentbody": "SABlAGwAbABvACAAVwBvAHIAbABkAA==",
"objectid@odata.bind": "/accounts(3ba2f6ab-3849-e811-a83b-000d3a2b2acb)",
"isdocument": true
"mimetype": "text/plain";
"subject": "testing from CRM Webapi 33";
}
这没有任何问题。 objectid_account@odata.bind
是绝对必要的,因为 objectid
可以存储任何实体。 Read more
var entity = {};
entity.subject = "arun test";
entity["objectid_account@odata.bind"] = "/accounts(4B91608D-3C5A-EA11-A811-000D3A5A1CAC)";
entity.notetext = "blah blah";
entity.filename = "arun.txt";
entity.documentbody = "SABlAGwAbABvACAAVwBvAHIAbABkAA==";
entity.isdocument = true;
Xrm.WebApi.online.createRecord("annotation", entity).then(
function success(result) {
var newEntityId = result.id;
},
function(error) {
Xrm.Utility.alertDialog(error.message);
}
);
我在发送附件时遇到了一些问题。它看起来像这样:
{
"filename": "Test.txt",
"subject": "Test",
"mimetype": "text/plain",
"documentbody": "SABlAGwAbABvACAAVwBvAHIAbABkAA==",
"objectid@odata.bind": "/accounts(3ba2f6ab-3849-e811-a83b-000d3a2b2acb)",
"isdocument": true
}
我得到的错误:
"error": {
"code": "0x0",
"message": "An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'objectid' which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values."
知道这里出了什么问题吗?我是不是定义错了注解和账号的关系?
试试下面,您缺少 MimeType,这对于了解附件的类型很重要。刚刚在我的一个系统上试过,它可以工作。
{
"filename": "Test.txt",
"documentbody": "SABlAGwAbABvACAAVwBvAHIAbABkAA==",
"objectid@odata.bind": "/accounts(3ba2f6ab-3849-e811-a83b-000d3a2b2acb)",
"isdocument": true
"mimetype": "text/plain";
"subject": "testing from CRM Webapi 33";
}
这没有任何问题。 objectid_account@odata.bind
是绝对必要的,因为 objectid
可以存储任何实体。 Read more
var entity = {};
entity.subject = "arun test";
entity["objectid_account@odata.bind"] = "/accounts(4B91608D-3C5A-EA11-A811-000D3A5A1CAC)";
entity.notetext = "blah blah";
entity.filename = "arun.txt";
entity.documentbody = "SABlAGwAbABvACAAVwBvAHIAbABkAA==";
entity.isdocument = true;
Xrm.WebApi.online.createRecord("annotation", entity).then(
function success(result) {
var newEntityId = result.id;
},
function(error) {
Xrm.Utility.alertDialog(error.message);
}
);