Automic Workload Automation

 View Only

  • 1.  Add user to user group via the REST API

    Posted 29 days ago

    In preparation for programmatically creating a new user via the REST API (need help, see thread), I wrote the following POC script to add an existing user to the existing user group. When I run it I get, the following. Anyone know where I'm going wrong?

    Enter password: <end point>/ae/api/v1/8251/objects/OPERATORS
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   282  100   158  100   124   1698   1333 --:--:-- --:--:-- --:--:--  3032
    Response: {
      "code" : 45106,
      "error" : "The request is invalid and cannot be processed by the Automation Engine.",
      "details" : "No detail information available."
    }

    #!/bin/bash

    REST_ENDPOINT="<end point>"
    CLIENT="8251"
    read -sp "Enter password: " PASSWORD
    AE_USER_PW="sblumenkrantz/CORP:$PASSWORD"
    # Construct the URL
    URL="$REST_ENDPOINT/ae/api/v1/${CLIENT}/objects/OPERATORS"
    echo ${URL}
    # JSON payload
    PAYLOAD=$(cat <<EOF
    {
       "data": {
          "usrg": {
          "members" : [ {
            "username" : "TEST_USER/TEST"
          } ]
       }
    }
    EOF
    )

    response=$(curl -X PATCH "${URL}" \
      --header "Content-Type: application/json" \
      --user "$AE_USER_PW" \
      --data "PAYLOAD}"
    # Output the response
    echo "Response: ${response}"



    -------------------------------------------


  • 2.  RE: Add user to user group via the REST API

    Broadcom Employee
    Posted 29 days ago

    Hi Steven,

    You can use the objects endpoint with PATCH to assign a user to a usergroup. 

    PATCH https://rest-....com/ae/api/v1/0/objects/TEST%2FTEST

    {
        "data": {
            "user": {
                "groups": [
                    {
                        "usergroup": "USER_ACCESS"
                    }
                ]
            }
        }
    }

    BR,

    Oana

    -------------------------------------------



  • 3.  RE: Add user to user group via the REST API

    Posted 28 days ago

    When I try the following script, I get the same response:

      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   166  100   158  100     8    487     24 --:--:-- --:--:-- --:--:--   513
    Response: {
      "code" : 45106,
      "error" : "The request is invalid and cannot be processed by the Automation Engine.",
      "details" : "No detail information available."
    }

    #!/bin/bash

    REST_ENDPOINT="<END POINT>"
    CLIENT="8251"
    read -sp "Enter password: " PASSWORD
    AE_USER_PW="sblumenkrantz/CORP:$PASSWORD"


    # Construct the URL
    URL="$REST_ENDPOINT/ae/api/v1/${CLIENT}/objects/TEST_USER%2FTEST"
    echo ${URL}
    # JSON payload
    PAYLOAD=$(cat <<EOF
    {
        "data": {
            "user": {
                "groups": [
                    {
                        "usergroup": "OPERATORS"
                    }
                ]
            }
        }
    }
    EOF
    )

    response=$(curl -X PATCH "${URL}" \
      --header "Content-Type: application/json" \
      --user "$AE_USER_PW" \
      --data "PAYLOAD}")
    # Output the response
    echo "Response: ${response}"

    -------------------------------------------



  • 4.  RE: Add user to user group via the REST API

    Posted 28 days ago

    With help from Oana, I was able to develop one script and one json structure that will create a new user and assign the user to a user group.

    Thanks for all who helped with all of this!

    -------------------------------------------