2017-08-17 20 views
0

使用版本1 API創建類型爲'Epic'的資產時出現錯誤。這是我的請求URL:多值屬性不能設置值。使用版本1 API創建Epic資產時使用AddValue和RemoveValue

URL:<Domain>/rest-1.v1/Data/Epic 

請求正文:

<?xml version="1.0" encoding="UTF-8"?> 
<Asset href="<Domain>/rest-1.v1/New/Epic"> 
    <Attribute name="Name" act="set">Test Epic Creation</Attribute> 
    <Relation name="Category"> 
     <Asset href="<Domain>/rest-1.v1/Data/EpicCategory/207" idref="EpicCategory:207"/> 
    </Relation> 
    <Attribute name="Category" act="set">EpicCategory:207</Attribute> 
    <Attribute name="Status" act="set">EpicStatus:64</Attribute> 
    <Attribute name="Custom_Product" act="set">Custom_Product:0</Attribute> 
    <Attribute name="Description" act="set">Test Epic Creation</Attribute> 
    <Relation name="Scope" act="set"> 
     <Asset href="<Domain>/rest-1.v1/Data/Scope/189675" idref="Scope:189675" /> 
    </Relation> 
    <Attribute name="StrategicThemes" act="add"> 
     <Value>StrategicTheme:5158</Value> 
    </Attribute> 
</Asset> 

這裏是我得到:

<Error href="<Domain>/rest-1.v1/Data/Epic"> 
    <Message>Server Error</Message> 
    <Exception class="System.NotSupportedException"> 
     <Message>Cannot SetValue on Multi-value attribute. Use AddValue and RemoveValue.</Message> 
    </Exception> 
</Error> 

問題我面臨的是在設置值的 StrategicThemes屬性這是一個多值屬性。

我被卡住了。請幫助。

回答

0

這是因爲值可以添加到多值屬性中,並且無法設置。值僅爲單值屬性設置。 此外,將值添加到StrategicThemes屬性的代碼不正確。

<Attribute name="StrategicThemes" act="add"> 
    <Value>StrategicTheme:5158</Value> 
</Attribute> 

因此,有問題的錯誤。

在用於多值屬性的值應添加爲:

<Relation name="StrategicThemes"> 
     <Asset idref="StrategicTheme:5158" act="add"/> 
</Relation>