Andrew1 wrote:
Hi people,
been playing with the restful web services in spectrum. (snip)
Good stuff, Andrew.
I had a follow-up example which you and others might find interesting: how to post
Events to Spectrum using the RESTful API.
DISCLAIMER: As of this posting, on 2012-12-03, CA has not updated the PDF manual[font=Courier New] Spectrum_Web_Services_API_Ref_ENU.pdf [font]to indicate any formal support for Event creation,
but based on a hint of possibility on the bottom of page 55 (first appearing in the manual with v9.2.2),
I tested the following, and it appears to function properly. YMMV.
1 - modify your code slightly, from:
$client->GET('spectrum/restful/devices?attr=0x12d7f&throttlesize=' . $HowMany);
to:
$client->POST('spectrum/restful/events', $xmlbody, undef );
2 - populate my extra variable [font=Courier New] $xmlbody [font]
with code from[font=Courier New] $SPECROOT/RestfulExamples/xml/Events/CreateEventByModelHandleList.xml [font]
This CA-supplied sample code, which is installed on
OneClick servers of v9.2.2 and newer, sets event[font=Courier New] 0x10f06 [font](High Memory Utilization) on a model.
3 - edit[font=Courier New] $xmlbody [font]:
In the line shown below, set the model handle to the model to which you want to send the event:
<rs:model mh="0x1026ff"/>
4 - execute as you describe, and your event magically appears on your model !
NOTE: of course, you should test this fully in a non-Production environment before trying it in Production !!!
HTH,
--Mark S
Mark Serencha – Inforonics Global Services, LLC – (m) +1-781-439-0519 – Mark.Serencha_AT_inforonics.com