Modifying an existing host

After logon, you must first search for the host and then you can modify an existing host.

Note: Etag is not supported as a header parameter in PUT requests in SMC API version 6.4 or higher. Use If-Match instead of Etag as a header parameter in PUT requests.

Search for the host using the filtering feature:

GET http://localhost:8082/7.1/elements/host?filter=mySrc1

After the element is found, use the following request:

GET http://localhost:8082/7.1/elements/host/1704

It returns the JSON host description and its ETag in the HTTP header in the following way:
Etag: MTcwNDMxMTEzNzQwNDMwNzM1NDQ=
    {
        "address": "192.168.0.13",
        "comment": "My SMC API's my Src Host 2",
        "key": 1704,
        "link":
        [
            {
                "href": "http://localhost:8082/7.1/elements/host/1704",
                "rel": "self",
                "type": "host"
            }
        ],
        "name": "mySrc2",
        "read_only": false,
        "secondary":
        [
            "10.0.0.156"
        ],
        "system": false,
        "third_party_monitoring":
        {
            "netflow": false,
            "snmp_trap": false
        }
}

From the JSON content, you can update the host as needed (add attributes, or add, remove, or update hosts).

PUT http://localhost:8082/7.1/elements/host/1704

Using If-Match: MTcwNDMxMTEzNzQwNDMwNzM1NDQ= as the HTTP request header, and the updated JSON content as the HTTP request payload, returns a 200 HTTP response status code and the following in the HTTP response header:

Location: http://localhost:8082/7.1/elements/host/1704

See updateHostThenDeleteIt.py JSON or XML samples.

If you use an incorrect Etag value in the If-Match request parameter, a 409 Conflict status code is shown.