0

成功使用 VersionOne API 使用 REST API 创建故事。不幸的是,描述字段似乎去除了所有 xml 标签。(网上的例子使用

,但这不起作用)

所以有类似的东西:

POST /VersionOne/rest-1.v1/Data/Story HTTP/1.1
Content-Type: text/xml; charset=utf-8
Content-Length: 221

<Asset>
    <Attribute name="Name" act="set">New Story</Attribute>
    <Relation name="Scope" act="set">
        <Asset idref="Scope:0" />
    </Relation>
        <Attribute name="Description" act="set"> 
          <p>first line</p> 
          <p> second line</p>
        </Attribute>
</Asset>

有什么方法可以插入格式?基本上,我们将此作为一个故事来测试我们最近创建的工件,并希望参考工件中包含的缺陷/故事。非常感谢任何帮助,谢谢。

4

2 回答 2

1

Jon,您需要对 Description 的文本值进行 XML 编码。两种可能性是:

<Asset>
    <Attribute name="Name" act="set">New Story</Attribute>
    <Relation name="Scope" act="set">
        <Asset idref="Scope:0" />
    </Relation>
        <Attribute name="Description" act="set"> 
          &lt;p&gt;first line&lt;/p&gt;
          &lt;p&gt; second line&lt;/p&gt;
        </Attribute>
</Asset>

或者

<Asset>
    <Attribute name="Name" act="set">New Story</Attribute>
    <Relation name="Scope" act="set">
        <Asset idref="Scope:0" />
    </Relation>
        <Attribute name="Description" act="set"><![CDATA[
          <p>first line</p> 
          <p> second line</p>
         ]]></Attribute>
</Asset>
于 2013-08-19T18:41:12.783 回答
0

您可以尝试使用 CDATA 部分,如下所示:

<Asset>
    <Attribute name="Description" act="set">
    <![CDATA[
        <xml>code goes here</xml>
    ]]>
    </Attribute>
</Asset>

当我对我们的公共测试服务器执行此操作时:https://www14.v1host.com/v1sdktesting/http.html并 POST 到默认的 Scope/0,我得到了这个:

<?xml version="1.0" encoding="UTF-8"?>
<Asset href="/v1sdktesting/rest-1.v1/Data/Scope/0/21470" id="Scope:0:21470">
        <Attribute name="Description">&lt;xml&gt;code goes here&lt;/xml&gt; </Attribute>
</Asset>

这有帮助吗?

于 2013-08-19T18:49:01.657 回答