cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2175
Views
0
Helpful
1
Replies

creating user groups using python script

Richie20
Level 1
Level 1

Hi everyone ,

I am creating internal user groups  through python script to ISE . I am  getting   this error while running the script

  "ERSResponse": {
        "operation""POST-create-internaluser",
        "messages": [
            {
                "title""Resource Initialization Failed: Invalid JSON: Unrecognized field \"User Groups\" (Class identity.InternalUser), not marked as ignorable\n ",
                "type""ERROR",
                "code""Application resource validation exception"
            }
        ],
        "link": {
            "rel""related",
            "href""https://192.169.39.19:9060/ers/config/internaluser",
            "type""application/xml"
        }
    }
}
this is my code :
import requests
import json


payload = json.dumps({
  "InternalUser": {
    "name""tet b",
    "password""C1sco4",
    "changePassword"False,
    "User Groups""Employee"
  }
})
headers = {
  'Content-Type''application/json',
  'Accept''application/json',
  'Authorization''Basic ZXJzYWRtaW46b0ZsUFJybmU0NTE=',
  'Cookie''APPSESSIONID=CC0213F7C85B124B22A7E88D5DDD7B8F; Cookie_1=value; JSESSIONIDSSO=A613BB7DCA4AD94866C0574D096B785D'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
 
Any suggestions are welcomed 
1 Accepted Solution

Accepted Solutions

Mike.Cifelli
VIP Alumni
VIP Alumni

"title": "Resource Initialization Failed: Invalid JSON: Unrecognized field \"User Groups\" (Class identity.InternalUser), not marked as ignorable\n "

-Your snippet shows that you are attempting to create (identified via POST) an internal user (identified via url).  You are getting that error because the following is not valid syntax when attempting to consume the internal user API:  "User Groups": "Employee"

 

This JSON request content example was extracted from the ERS Online SDK in regard to the internal user API:

JSON
{
  "InternalUser": {
    "name": "name",
    "description": "description",
    "enabled": true,
    "email": "email@domain.com",
    "password": "password",
    "firstName": "firstName",
    "lastName": "lastName",
    "changePassword": true,
    "identityGroups": "identityGroups",
    "expiryDateEnabled": false,
    "expiryDate": "2016-12-11",
    "enablePassword": "enablePassword",
    "customAttributes": {
      "key1": "value1",
      "key2": "value3"
    },
    "passwordIDStore": "Internal Users"
  }
}

If your end goal is to an Identity Group then the URL for consumption would look like this: https://x.x.x.x:9060/ers/config/identitygroup

JSON context example from SDK:

JSON
{
  "IdentityGroup": {
    "name": "name",
    "description": "description",
    "parent": "parent"
  }
}

I strongly suggest taking a look at the following resources:

ERS SDK: https://<ise_pan_ip>:9060/ers/sdk#

ISE ERS API Examples - Cisco Community

HTH!

View solution in original post

1 Reply 1

Mike.Cifelli
VIP Alumni
VIP Alumni

"title": "Resource Initialization Failed: Invalid JSON: Unrecognized field \"User Groups\" (Class identity.InternalUser), not marked as ignorable\n "

-Your snippet shows that you are attempting to create (identified via POST) an internal user (identified via url).  You are getting that error because the following is not valid syntax when attempting to consume the internal user API:  "User Groups": "Employee"

 

This JSON request content example was extracted from the ERS Online SDK in regard to the internal user API:

JSON
{
  "InternalUser": {
    "name": "name",
    "description": "description",
    "enabled": true,
    "email": "email@domain.com",
    "password": "password",
    "firstName": "firstName",
    "lastName": "lastName",
    "changePassword": true,
    "identityGroups": "identityGroups",
    "expiryDateEnabled": false,
    "expiryDate": "2016-12-11",
    "enablePassword": "enablePassword",
    "customAttributes": {
      "key1": "value1",
      "key2": "value3"
    },
    "passwordIDStore": "Internal Users"
  }
}

If your end goal is to an Identity Group then the URL for consumption would look like this: https://x.x.x.x:9060/ers/config/identitygroup

JSON context example from SDK:

JSON
{
  "IdentityGroup": {
    "name": "name",
    "description": "description",
    "parent": "parent"
  }
}

I strongly suggest taking a look at the following resources:

ERS SDK: https://<ise_pan_ip>:9060/ers/sdk#

ISE ERS API Examples - Cisco Community

HTH!