使用Dynamics CRM Web API创建帖子 [英] Creating Post with Dynamics CRM Web API

本文介绍了使用Dynamics CRM Web API创建帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

邮政实体( https://msdn.microsoft.com/en -us/library/mt607553.aspx )不能使用Dynamics CRM 2016在线Web API创建.

A Post entity (https://msdn.microsoft.com/en-us/library/mt607553.aspx) cannot be created using Dynamics CRM 2016 Online Web API.

此有效负载应在POST /api/data/v8.1/posts

{
    "text": "Test Single Post",
    "source": 1,
    "type": 7
}

(来源1是自动发布,类型7是状态发布)

(source 1 is an auto post, type 7 is a status post)

但是它返回:

{
    "error":
    {
        "code":"",
        "message":"An unexpected error occurred.",
        "innererror"
        {
            "message":"An unexpected error occurred..."
        }
    }
}

仅使用文本"提交相同的有效载荷也将失败.

Submitting the same payload with only "text" fails too.

请注意,Post实体不具有单值导航属性( https://msdn.microsoft.com/zh-cn/library/mt607553.aspx#bkmk_SingleValuedNavigationProperties ),这将允许我设置相关实体​​(联系人,客户等).

Notice that the Post entity does not have single-valued navigation properties (https://msdn.microsoft.com/en-us/library/mt607553.aspx#bkmk_SingleValuedNavigationProperties) that will allow me to set the related entity (contact, account, etc).

例如,创建任务实体( https://msdn.microsoft .com/en-us/library/mt607619.aspx )在POST /api/data/v8.1/tasks

For example, Creating a Task entity (https://msdn.microsoft.com/en-us/library/mt607619.aspx) works fine on POST /api/data/v8.1/tasks

{
    "subject": "Test Single Task",
    "description": "Test One Description of Task",
    "regardingobjectid_contact_task@odata.bind": "/contacts(<someguid>)",
    "scheduledend": "2016-07-21T12:11:19.4875892Z"
}

在我看来,Post应该公开类似regardingobjectid_contact_post@odata.bind的内容,但事实并非如此.

It seems to me that Post should expose something like regardingobjectid_contact_post@odata.bind, but it does not.

对于上下文,这是通过SOAP端点和SDK创建帖子的方法:

For context, this is how to create a Post via the SOAP endpoint and the SDK:

var result = Client.getOrganizationService().Create(new Post
{
    Text = post.text,
    RegardingObjectId = new EntityReference(
        entityName,
        Guid.Parse(post.regarding_guid)
    )
});

有人通过Web API创建了一个可行的帖子示例吗?这是Dynamics CRM Web API中的遗漏吗?

Does anyone have a working example of a Post created via the Web API? Is this an omission in the Dynamics CRM Web API?

此限制中未列出以下内容: https: //msdn.microsoft.com/zh-CN/library/mt628816.aspx

It doesn't look like this is listed in the limitations: https://msdn.microsoft.com/en-us/library/mt628816.aspx

更新

似乎应该在后实体中创建用于联系/帐户的链接.这可以通过查询来证明:

It appears that the postregarding entity is where the link should be created to contact/account. This can be demonstrated by querying:

/posts?$filter=postregardingid/regardingobjectid_contact/contactid eq <someguid>

但是,像这样的深度插入"无效:

However, a "deep insert" like so does not work:

{
    "text":"sometext",
    "postregardingid": 
         {
             "regardingobjectid_contact@odata.bind":"/contacts(someguid)"
         }
}

响应为

无法在父实体之前创建子实体.

Cannot create child entities before parent entity.

推荐答案

在任何地方都无法使用Webapi创建帖子(活动供稿).实际上,它没有像您指出的那样列为crm webapi限制.

Nowhere it's mentioned like Post (activity feed) cannot be created using webapi. In fact it's not listed as crm webapi limitation like you pointed out.

在比较中,发布的_regardingobjectid_value查找属性 activitypointer 不同.也是单值导航属性.

Also on comparison, _regardingobjectid_value lookup property of post is different from activitypointer. Single valued navigation property too.

出于好奇,我的调查转向了合作伙伴-post_PostRegardings

Out of curiosity, My investigation moved towards the Partner - post_PostRegardings

只有有意义的内容-postregarding严格仅供内部使用.这可能是所有此类行为的原因.根据今天的v8.2,这是我的理论(2017年8月12日)

Only thing making sense - postregarding is strictly internal use. This could be the reason for all such behavior. This is my theory per v8.2 today(Aug 12 2017)

说明:表示活动供稿帖子涉及的对象. 仅供内部使用.
实体集路径:[组织URI]/api/data/v8.2/postregardings
基本类型:crmbaseentity EntityType
显示名称:关于以下内容的帖子:
主键:后置ID

Description: Represents which object an activity feed post is regarding. For internal use only.
Entity Set path:[organization URI]/api/data/v8.2/postregardings
Base Type: crmbaseentity EntityType
Display Name: Post Regarding
Primary Key: postregardingid

引用: https://msdn.microsoft.com/zh-CN /library/mt608103.aspx

更新:

看起来像MS推荐社区使用组织服务来创建自定义的Post记录. Web API仍然损坏.

Looks like MS recommend the community to use Organization service to create a custom Post record. Web api is still broken. Read more

这篇关于使用Dynamics CRM Web API创建帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆