Retrieving entities

You can retrieve information about a solution entity by sending a GET operation request to the Insight Server. The response to the GET request includes a single entity representation that is identified by the entity ID.

About this task

By default, the retrieved information is returned in XML format. You can change the returned format by setting the value to JSON. The choice of the output format is based on the tool you are using to receive the data. For more information on how to read and interpret JSON output, see JSON mapping.

Procedure

  1. Make sure you can access the Insight Server by entering the generic REST URL in the browser address field. See Managing entities for an example of the REST URL.
  2. Using your browser, or a script, send a GET request to retrieve information about an entity. For example:
    https://localhost:9443/ibm/ia/rest/solutions/BankingSolution/entity-types/CustomerID/entities/200
    where the ID of the customer entity is 200.
    The returned content is as follows:
    <object xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.ibm.com/ia/Entity" type="com.example.model.ComplexEntity">
      <attribute name="$CreationTime">
        <null/>
      </attribute>
      <attribute name="$IdAttrib">
        <string>id</string>
      </attribute>
      <attribute name="complexEvent">
        <object type="com.example.model.ComplexEvent">
          <attribute name="$Id">
            <string>25AAE2D8845270CAB511E5A3BE8C0B69</string>
          </attribute>
          <attribute name="$TimeAttrib">
            <string>datetime</string>
          </attribute>
          <attribute name="completed">
            <boolean>false</boolean>
          </attribute>
          <attribute name="complexEntities">
            <collection>
              <object type="com.ibm.ia.model.Relationship">
                <attribute name="key">
                  <string>E0025</string>
                </attribute>
                <attribute name="type">
                  <string>com.example.model.ComplexEntity</string>
                </attribute>
             
              </object>
              <object type="com.ibm.ia.model.Relationship">
                <attribute name="key">
                  <string>E0014</string>
                </attribute>
                <attribute name="type">
                  <string>com.example.model.ComplexEntity</string>
                </attribute>
             
              </object>
            </collection>
          </attribute>
          <attribute name="datetime">
            <null/>
          </attribute>
          <attribute name="value">
            <string>test</string>
          </attribute>
       
        </object>
      </attribute>
      <attribute name="enumType">
        <object type="com.example.model.EnumType" staticReference="gamma"/>
       
      </attribute>
      <attribute name="id">
        <string>E0025</string>
      </attribute>
      <attribute name="testConcepts">
        <collection>
          <object type="com.example.model.TestConcept">
            <attribute name="value">
              <int>3643</int>
            </attribute>
         
          </object>
          <object type="com.example.model.TestConcept">
            <attribute name="value">
              <int>-771</int>
            </attribute>
         
          </object>
        </collection>
      </attribute>
    
    </object>
    You can include an optional regex parameter in the GET request. Add a regular expression (regex) query string to the GET request to retrieve an entity, or set of entities, that match the expression. If the query includes an entity ID or range of entity IDs, only entities with IDs that match are returned in the server response. For example:
    https://localhost:9443/ibm/ia/rest/solutions/BankingSolution/entity-types/CustomerID?regex=20[0-5]
    where entities with the ID 200, 201, 202, 203, 204 or 205 are returned in response to the GET request.
  3. Optional: In the Accept request header, set the value to application/json to retrieve information about an entity in the JSON format. For example:
    https://localhost:9443/ibm/ia/rest/solutions/BankingSolution/entity-types/CustomerID/entities/200
    where the ID of the customer entity is 200.
    The returned content is as follows:
    {
      "$class": "com.example.model.ComplexEntity",
      "$CreationTime": null,
      "$IdAttrib": "id",
      "complexEvent": {
        "$Id": "25AAE2D8845270CAB511E5A3BE8C0B69",
        "$TimeAttrib": "datetime",
        "completed": false,
        "complexEntities": [
          {
            "$class": "com.ibm.ia.model.Relationship",
            "key": "E0025",
            "type": "com.example.model.ComplexEntity"
          },
          {
            "$class": "com.ibm.ia.model.Relationship",
            "key": "E0014",
            "type": "com.example.model.ComplexEntity"
          }
        ],
        "datetime": null,
        "value": "test"
      },
      "enumType": "gamma",
      "id": "E0025",
      "testConcepts": [
        {
          "value": 3643
        },
        {
          "value": -771
        }
      ]
    }
  4. Optional: Include the If-None-Match request header and ETag header to return only entities that changed since the previous request.
    Tip: If you make frequent GET requests, or a large number of entities is returned by your GET requests, the volume of requests might affect event processing performance. Use the ETag header to optimize entity retrieval and improve processing speed.