Jon Burgin
Jon Burgin

Reputation: 83

VersionOne rest API description attribute format

Successfully using the VersionOne API to create stories using the REST API. Unfortunately the description field seems to strip all xml tags. (The example online uses

, but this does not work)

So have something like:

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>

Any way to insert formatting? Basically we are using this as a story to test our recently created artifact and want to refer to the defects/stories that are included in the artifact. Any help much appreciated, thanks.

Upvotes: 0

Views: 639

Answers (2)

JoshGough
JoshGough

Reputation: 974

You could try to use CDATA sections, like this:

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

When I do this against our public test server: https://www14.v1host.com/v1sdktesting/http.html, and POST to the default Scope/0, I get this:

<?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>

Does this help?

Upvotes: 0

spazmodius
spazmodius

Reputation: 37

Jon, you'll need to XML-encode the text value of Description. Two possibilities are:

<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>

or

<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>

Upvotes: 1

Related Questions