<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Using ISE API for Authorization Profiles in Network Access Control</title>
    <link>https://community.cisco.com/t5/network-access-control/using-ise-api-for-authorization-profiles/m-p/5283083#M596015</link>
    <description>&lt;P&gt;I am trying to use the ISE API to create my bulk Authorization profiles. I write the following Python Code. This code create Authorization profiles, but I still unable to select and change the the Advanced Attributes parts of the profiles when I create them.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="imanv_0-1745139855198.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.cisco.com/t5/image/serverpage/image-id/243743i0D62D3BCDC345D26/image-size/medium?v=v2&amp;amp;px=400" role="button" title="imanv_0-1745139855198.jpeg" alt="imanv_0-1745139855198.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import logging
import pandas as pd
from ciscoisesdk import api, ApiError, ciscoisesdkException
import json

# Set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

def create_authorization_profile(api_, policy_name, access_type, profile_name, left_dictionary_name, left_attribute_name, value):
    try:
        profile_data = {
            "name": policy_name,
            "profileName": profile_name,
            "accessType": access_type,
            "advancedAttributes": {
                "leftHandSideDictionaryAttribute": [
                    {
                        "dictionaryName": left_dictionary_name,
                        "attributeName": left_attribute_name,
                        "value": value
                    }
                ]
            },
            "description": "Created via Python bulk script"
        }

        # Log the request payload
        logging.debug(f"Request Data: {json.dumps(profile_data, indent=2)}")

        # Make the API call to create the authorization profile
        response = api_.authorization_profile.create_authorization_profile(**profile_data)

        if hasattr(response, 'response'):
            logging.info(f"&lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Profile '{policy_name}' created successfully.")
        else:
            logging.warning(f"&lt;span class="lia-unicode-emoji" title=":warning:"&gt;⚠️&lt;/span&gt; Unexpected response type: {type(response)}")

    except ApiError as e:
        logging.error(f"&lt;span class="lia-unicode-emoji" title=":cross_mark:"&gt;❌&lt;/span&gt; API Error while creating profile '{policy_name}': {e}")
        if hasattr(e, 'response'):
            logging.debug(f"Error Response: {e.response.text}")
    except ciscoisesdkException as e:
        logging.warning(f"&lt;span class="lia-unicode-emoji" title=":cross_mark:"&gt;❌&lt;/span&gt; SDK Exception while creating profile '{policy_name}': {e}")
    except Exception as e:
        logging.exception(f"&lt;span class="lia-unicode-emoji" title=":cross_mark:"&gt;❌&lt;/span&gt; General error while creating profile '{policy_name}': {e}")

def main():
    # Initialize Cisco ISE API client
    api_ = api.IdentityServicesEngineAPI(
        username="ers-user",  # Replace with your username
        password="password(",  # Replace with your password
        base_url="https://10.10.10.10",  # Replace with your ISE FQDN or IP
        version='3.3',  # Match your ISE version
        verify=False,  # Set True if using trusted certs
        debug=True,
        uses_api_gateway=True,
        uses_csrf_token=False
    )

    # Load Excel file
    excel_path = "C:\\Authorization_policies.xlsx"
    try:
        df = pd.read_excel(excel_path)
        logging.info(f"&lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Loaded Excel file: {excel_path}")
    except Exception as e:
        logging.error(f"&lt;span class="lia-unicode-emoji" title=":cross_mark:"&gt;❌&lt;/span&gt; Failed to load Excel file: {e}")
        return

    # Iterate through each row and create profiles
    for index, row in df.iterrows():
        policy_name = row.get('Policy Name')
        access_type = row.get('Access Type', 'ACCESS_ACCEPT')
        profile_name = row.get('Profile Name', 'Cisco')
        left_dictionary_name = row.get('Left_dictionaryName')
        left_attribute_name = row.get('Left_attributeName')
        value = row.get('Value')

        if policy_name and left_dictionary_name and left_attribute_name and value:
            create_authorization_profile(
                api_,
                policy_name.strip(),
                access_type.strip() if isinstance(access_type, str) else access_type,
                profile_name.strip() if isinstance(profile_name, str) else profile_name,
                left_dictionary_name.strip(),
                left_attribute_name.strip(),
                str(value).strip()
            )
        else:
            logging.warning(f"&lt;span class="lia-unicode-emoji" title=":warning:"&gt;⚠️&lt;/span&gt; Skipping row {index + 1}: Missing required fields.")

    logging.info("&lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Bulk profile creation completed.")

if __name__ == "__main__":
    main()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will appreciation if you able to help me to write the correct code.&lt;/P&gt;&lt;P&gt;ISE Version : 3.3 Patch 4&lt;/P&gt;&lt;P&gt;Python Version: 3&lt;/P&gt;</description>
    <pubDate>Sun, 20 Apr 2025 09:12:18 GMT</pubDate>
    <dc:creator>imanv</dc:creator>
    <dc:date>2025-04-20T09:12:18Z</dc:date>
    <item>
      <title>Using ISE API for Authorization Profiles</title>
      <link>https://community.cisco.com/t5/network-access-control/using-ise-api-for-authorization-profiles/m-p/5283083#M596015</link>
      <description>&lt;P&gt;I am trying to use the ISE API to create my bulk Authorization profiles. I write the following Python Code. This code create Authorization profiles, but I still unable to select and change the the Advanced Attributes parts of the profiles when I create them.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="imanv_0-1745139855198.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.cisco.com/t5/image/serverpage/image-id/243743i0D62D3BCDC345D26/image-size/medium?v=v2&amp;amp;px=400" role="button" title="imanv_0-1745139855198.jpeg" alt="imanv_0-1745139855198.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import logging
import pandas as pd
from ciscoisesdk import api, ApiError, ciscoisesdkException
import json

# Set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

def create_authorization_profile(api_, policy_name, access_type, profile_name, left_dictionary_name, left_attribute_name, value):
    try:
        profile_data = {
            "name": policy_name,
            "profileName": profile_name,
            "accessType": access_type,
            "advancedAttributes": {
                "leftHandSideDictionaryAttribute": [
                    {
                        "dictionaryName": left_dictionary_name,
                        "attributeName": left_attribute_name,
                        "value": value
                    }
                ]
            },
            "description": "Created via Python bulk script"
        }

        # Log the request payload
        logging.debug(f"Request Data: {json.dumps(profile_data, indent=2)}")

        # Make the API call to create the authorization profile
        response = api_.authorization_profile.create_authorization_profile(**profile_data)

        if hasattr(response, 'response'):
            logging.info(f"&lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Profile '{policy_name}' created successfully.")
        else:
            logging.warning(f"&lt;span class="lia-unicode-emoji" title=":warning:"&gt;⚠️&lt;/span&gt; Unexpected response type: {type(response)}")

    except ApiError as e:
        logging.error(f"&lt;span class="lia-unicode-emoji" title=":cross_mark:"&gt;❌&lt;/span&gt; API Error while creating profile '{policy_name}': {e}")
        if hasattr(e, 'response'):
            logging.debug(f"Error Response: {e.response.text}")
    except ciscoisesdkException as e:
        logging.warning(f"&lt;span class="lia-unicode-emoji" title=":cross_mark:"&gt;❌&lt;/span&gt; SDK Exception while creating profile '{policy_name}': {e}")
    except Exception as e:
        logging.exception(f"&lt;span class="lia-unicode-emoji" title=":cross_mark:"&gt;❌&lt;/span&gt; General error while creating profile '{policy_name}': {e}")

def main():
    # Initialize Cisco ISE API client
    api_ = api.IdentityServicesEngineAPI(
        username="ers-user",  # Replace with your username
        password="password(",  # Replace with your password
        base_url="https://10.10.10.10",  # Replace with your ISE FQDN or IP
        version='3.3',  # Match your ISE version
        verify=False,  # Set True if using trusted certs
        debug=True,
        uses_api_gateway=True,
        uses_csrf_token=False
    )

    # Load Excel file
    excel_path = "C:\\Authorization_policies.xlsx"
    try:
        df = pd.read_excel(excel_path)
        logging.info(f"&lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Loaded Excel file: {excel_path}")
    except Exception as e:
        logging.error(f"&lt;span class="lia-unicode-emoji" title=":cross_mark:"&gt;❌&lt;/span&gt; Failed to load Excel file: {e}")
        return

    # Iterate through each row and create profiles
    for index, row in df.iterrows():
        policy_name = row.get('Policy Name')
        access_type = row.get('Access Type', 'ACCESS_ACCEPT')
        profile_name = row.get('Profile Name', 'Cisco')
        left_dictionary_name = row.get('Left_dictionaryName')
        left_attribute_name = row.get('Left_attributeName')
        value = row.get('Value')

        if policy_name and left_dictionary_name and left_attribute_name and value:
            create_authorization_profile(
                api_,
                policy_name.strip(),
                access_type.strip() if isinstance(access_type, str) else access_type,
                profile_name.strip() if isinstance(profile_name, str) else profile_name,
                left_dictionary_name.strip(),
                left_attribute_name.strip(),
                str(value).strip()
            )
        else:
            logging.warning(f"&lt;span class="lia-unicode-emoji" title=":warning:"&gt;⚠️&lt;/span&gt; Skipping row {index + 1}: Missing required fields.")

    logging.info("&lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Bulk profile creation completed.")

if __name__ == "__main__":
    main()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will appreciation if you able to help me to write the correct code.&lt;/P&gt;&lt;P&gt;ISE Version : 3.3 Patch 4&lt;/P&gt;&lt;P&gt;Python Version: 3&lt;/P&gt;</description>
      <pubDate>Sun, 20 Apr 2025 09:12:18 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-access-control/using-ise-api-for-authorization-profiles/m-p/5283083#M596015</guid>
      <dc:creator>imanv</dc:creator>
      <dc:date>2025-04-20T09:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using ISE API for Authorization Profiles</title>
      <link>https://community.cisco.com/t5/network-access-control/using-ise-api-for-authorization-profiles/m-p/5284238#M596057</link>
      <description>&lt;P&gt;I found the problem I want you to know it as well.&lt;/P&gt;&lt;P&gt;The problem was at &lt;EM&gt;advancedAttributes&amp;nbsp;&lt;/EM&gt;in the code. I should write it &lt;EM&gt;advanced_Attributes.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 10:30:10 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-access-control/using-ise-api-for-authorization-profiles/m-p/5284238#M596057</guid>
      <dc:creator>imanv</dc:creator>
      <dc:date>2025-04-23T10:30:10Z</dc:date>
    </item>
  </channel>
</rss>

