Spectrum - Update dynamicCriteriaXML attribute using REST

book

Article ID: 130786

calendar_today

Updated On:

Products

CA Spectrum

Issue/Introduction

I am unable to update the attribute (0x12a6a) using the REST API consistently.
This is the dynamicCriteriaXML attribute where the search criteria for a Global Collection are stored.
I can update sometimes depending on the search criteria I use and it works fine using Spectrum CLI.

In the following example I am trying to set the the search criteria to find models where the isManaged attribute (0x1295d) is false. The equivalent XML is as follows ...
 
<search-criteria>
<devices-only-search />
<filtered-models>
<and>
<equals>
<attribute id="0x1295d">
<value>false</value>
</attribute>
</equals>
</and>
</filtered-models>
</search-criteria>
 
But this gives the error
 
Invalid attribute value: Error reading search criteria file /opt/spectrum/tomcat/webapps/spectrum/./WEB-INF/<search-criteria>
<devices-only-search />
<filtered-models>
<and>
<equals>
<attribute id.xml:

The following works
Set the search criteria for to find models where the model-class is 2. The equivalent XML that I am updating the attribute 0x12a6a with is

<search-criteria> 
<devices-only-search /> 
<filtered-models> 
<and> 
<equals> 
<model-class>2</model-class> 
</equals> 
</and> 
</filtered-models> 
</search-criteria> 

Environment

Release:
Component: SPCINT

Resolution

To change the value of model attributes, we document

PUT model
PUT model updates attributes on the specified model.
URL
http://<hostname><:portnumber>/spectrum/restful/model/<model_handle>?attr=<attr_ID>&val=<num>
HTTP Method
PUT
Body
None
Body Content
Not Used
Header
application/xml, application/json
Output
XML or JSON listing of the requested attributes
URL Parameters
Specifies the model to update.
&attr=<attr_ID>&val=<num>
Specifies the attributes and values to update. Multiple attribute-value pairs can be specified.

e.g Using a dynamic GC called “dynamic test”, which was created manually has the following value for the 0x12a6a attribute.
 
<search-criteria>
<filtered-models>
<equals>
<attribute id="0x1000a">
<value>3</value>
</attribute>
</equals>
</filtered-models>
</search-criteria>

Which could be used to make this query that fails with the aforementioned error.
http://localhost/spectrum/restful/model/0x4056b96?attr=0x12a6a&val=<search-criteria>  <filtered-models>  <equals>  <attribute id="0x1000a">  <value>3</value>  </attribute>  </equals>  </filtered-models>  </search-criteria>




However, this needs to be encoded to escape certain characters.
I did this from my client automatically (ARC) as follows:

http://localhost/spectrum/restful/model/0x4056b96?attr=0x12a6a&val=%3Csearch-criteria%3E+%3Cfiltered-models%3E+%3Cequals%3E+%3Cattribute+id%3D%220x1000a%22%3E+%3Cvalue%3E3%3C%2Fvalue%3E+%3C%2Fattribute%3E+%3C%2Fequals%3E+%3C%2Ffiltered-models%3E+%3C%2Fsearch-criteria%3E

This gives the correct result

 

Additional Information


http://techdocs.broadcom.com/content/broadcom/techdocs/us/en/ca-enterprise-software/it-operations-management/spectrum/10-4-1/programming/web-services-api-reference/how-to-use-the-ca-spectrum-web-services-api/restful-resources-nouns/model.html#concept.dita_1d06a0d76f000e6edd18de492383983feefced4e_PUTmodel

Attachments

1558687531812000130786_sktwi1f5rjvs16fba.jpeg get_app
1558687529745000130786_sktwi1f5rjvs16fb9.jpeg get_app
1558687526744000130786_sktwi1f5rjvs16fb8.jpeg get_app