Example task using the web API

Prev Next

You can accomplish many simple tasks using the ePO - On-prem web API. This complete example demonstrates the suggested steps to complete a task.

This example allows you to use the web API to assign a policy to a group.

  1. Use this Help request to find out what the policy.assignToGroup command requires.

    > curl -k -u ga:ga "https://localhost:8443/remote/core.help?command=policy.assignToGroup"

    This command displays:

    OK:
    policy.assignToGroup groupId productId objectId [resetInheritance]
    Assigns policy to the specified group or resets group's inheritance for the specified policy
    Requires permission to at least one group in the System Tree and edit permission for at least one product
    Parameters:
     groupId (param 1) - Group ID as returned by system.findGroups 
     productId (param 2) - Product ID as returned by policy.find
     objectId (param 3) - Object ID as returned by policy.find
     resetInheritance (param 4) - If true resets the inheritance for the specified policy on the given group. Defaults to false.

    This Help request shows that there are three required arguments:

    • Group ID

    • ID for the product you want to assign

    • Object ID of the policy to assign.

      Note

      You could also reset the inheritance, but that argument is not required, and is not used it in this example.

  2. Use the system.findGroups command to find the group ID.

    > curl -k -u ga:ga "https://localhost:8443/remote/system.findGroups?searchText=My%20Group"

    That command returns a result similar to this:

    OK:
    groupId: 2
    groupPath: My Organization
    
    groupId: 4
    groupPath: My Organization\My Group
  3. Use this policy.find command to find the product ID and policy object ID:

    > curl -k -u ga:ga "https://localhost:8443/remote/policy.find?searchText=quarantine"

    That command returns two results:

    OK:
    featureId: VIRUSCAN8800
    featureName: VirusScan Enterprise
    objectId: 131
    objectName: McAfee Default
    objectNotes: 
    productId: VIRUSCAN8800
    productName: VirusScan Enterprise 8.8.0
    typeId: 67
    typeName: Quarantine Manager Policies
    
    featureId: VIRUSCAN8800
    featureName: VirusScan Enterprise
    objectId: 142
    objectName: My Default
    objectNotes: 
    productId: VIRUSCAN8800
    productName: VirusScan Enterprise 8.8.0
    typeId: 67
    typeName: Quarantine Manager Policies
  4. Choose one of policy.find results. This example uses the My Default policy and you have the necessary information required to assign a policy to a group with this information:

    • Group ID — 4

    • Product ID — VIRUSCAN8800

    • Policy object ID — 142

  5. Use the previous information and this policy.assignToGroup command to assign a policy to a group:

    > curl -k -u ga:ga https://localhost:8443/remote/policy.assignToGroup -d "groupId=4&productId=VIRUSCAN8800&objectId=142"

    This returns:

    OK: 
    True

    The policy is assigned.

RESULT_F67A447F604F438298501DF7A0FE7CF1 In general, the web API commands return three kinds of results:

  1. True or False results indicating the command's success or failure

  2. Data returned from the command

  3. Multiple data items and which items succeeded or failed