3

我正在尝试在 VersionOne 中创建一个新的“表达式” - 有效地将新的“评论”添加到对话中。

理论上,rest-1.v1/Data API 应该允许这样做,但我不知道该怎么做——关于使用 API(使用 POST)创建对象的文档很少。

FWIW,这就是我正在做的事情(在使用有效凭据成功访问服务器之后):

网址:/rest-1.v1/Data/Expression

XML:

<Asset href="<Server Base URI>/rest-1.v1/Data/Expression">
<Attribute name="AssetType">Expression</Attribute>
<Relation name="InReplyTo" />
<Attribute name="AuthoredAt">2014-05-28T21:48:37.940</Attribute>
<Attribute name="Content">A new comment</Attribute>
<Attribute name="AssetState">64</Attribute>
<Relation name="Author">
  <Asset href="<Server Base URI>/rest-1.v1/Data/Member/2015" idref="Member:2015" />
</Relation>
<Relation name="BelongsTo">
  <Asset href="<Server Base URI>/rest-1.v1/Data/Conversation/2018" idref="Conversation:2018" />
</Relation>
<Attribute name="Author.Name">user@example.com</Attribute>
<Attribute name="Author.Nickname">User Name</Attribute>
<Relation name="Mentions">
  <Asset href="<Server Base URI>/rest-1.v1/Data/Story/2017" idref="Story:2017" />
</Relation>
</Asset>

我不断收到 400 Bad Request 以下错误:

<Error href="<Server Base URI>/rest-1.v1/Data/Expression">
<Message>Violation'Required'AttributeDefinition'Content'Expression</Message>
<Exception class="VersionOne.DataException">
<Message>Violation'Required'AttributeDefinition'Content'Expression</Message>
</Exception>
</Error>

我想我遗漏了一些明显的东西——有人知道它是什么吗?

4

1 回答 1

2

如果您检查 VersionOne 表达式的元数据,您将看到 3 个必填字段(作者、AuthoredAt、内容)。从逻辑上讲,能够只创建一个僵尸表达式是有道理的,但我目睹了其他情况。这可能是样式表中的错误,或者只是我的浏览器中的错误,因为似乎只使用这三个 POST 会返回 400 错误。要获得有保证的有效负载,请包含关系“inReplyTo”,这就是在特定对话的上下文中创建表达式所需的全部内容。

鉴于您正在响应现有表达式(评论),这应该可以正常工作。

POST to rest-1.v1/Data/Expression

<Asset>
  <Relation name="Author" act="set">
     <Asset idref="Member:2015" />
  </Relation>

  <Attribute name="AuthoredAt">2014-05-02T21:48:37.940</Attribute>  

  <Attribute name="Content" act="set">A new comment</Attribute>

  <Relation name="InReplyTo" act="set">
     <Asset idref="Expression:xxxxx" /> 
  </Relation>
</Asset>

您不需要资产状态或提及或所属。AssetState 是只读的,BelongsTo 会在你的 Expression 创建后自动填写。它从 InReplyTo 字段中输入的 Expression 对象继承对包含 Conversation 的引用,并且 Mentions 关系是可选的。

仅供参考,我相信您没有在浏览器中看到元查询输出右侧的图例。在这里真的很快,当您进行元查询时,带有 * 的项目需要发布,粗体项目是读/写可选的,斜体项目是只读的,底部的粗体项目附加“:操作”是允许您针对该特定资产执行的操作。

于 2014-06-02T19:02:09.043 回答