Modify events

You can modify events (read, create, update and delete items) using a REST client within your web browser, or using the RestWsUtil command-line utility.

Note With OMi 9.10 and higher, Event Web Service modify operations must be secured by setting the X-Secure-Modify-Token HTTP header on modify requests (PUT, POST, and DELETE). This header provides enhanced security protection against malicious exploits of web applications. For more information, see Secure modify operations.

Modifying events using a REST client

In general, when using a REST client to update an event, it is usual to do the following:

  • Call the REST service by entering the URL of the event in question (you need to specify the event ID in the URL).

  • Retrieve the event with an HTTP GET request.

  • Edit the elements of the XML document you want to change.

  • Send back the changed parts of the event using an HTTP PUT request.

  • Reload the XML to see the changes.

Two examples of REST clients that can be used to modify events are the REST Client and the Mozilla Firefox Poster Extension.

Modifying events using the RestWsUtil utility

A REST web service utility is provided to allow you to execute REST web service operations against the event web service from the command-line. With this utility, you can execute one of the four following REST web service operations:

CRUD Operation

HTTP Method

Create

POST

Read

GET

Update

PUT

Delete

DELETE

You can find the utility in the following location:

<OMi_HOME>/opr/bin

You can modify events using the RestWsUtil command-line utility.

Example: How to Change an Event Title

To change the title of an event using the RestWsUtil utility, follow these steps:

  1. Get the event ID of the event you want to modify.

  2. Write the XML for the event you want to modify to an XML file (called, for example, update.xml) in the <OMi_HOME>/opr/bin directory.

    The contents of the update.xml file look like this:

    <event xmlns="http://www.hp.com/2009/software/opr/data_model"><title>
    New title goes here</title></event>

    Edit the title.

  3. To update and save the change, enter the following command in a command prompt:

    <OMi_HOME>/opr/bin>RestWsUtil -update update.xml -username <login name> -password <password> -url "https://<server.example.com>/opr-web/rest/9.10/event_list/<event_ID>"

    Where:

    <OMi_HOME> is the directory where OMi is installed, <login name> is the user name required for authentication, and <event_ID> is the ID of the event you want to modify.

For further details and examples of how to use the RestWsUtil command-line utility, see RestWsUtil Command-Line Interface.