Null identity on create access profile API

Hello, everyone

I’m trying to create a script to automate the creation of access profiles on my ISC enviroment, i followed the sailpoint documentation to build the script and also tried to do the request through a http client (insomnia) but i always get the following error:

I already checked the content and tried diferent identities that are being used as owners in others existing access profiles, here is the script i’m trying to execute:

import csv

import subprocess

import requests

import json




# ===== CONFIG =====

BASE_URL = "https://my-tenant.api.identitynow.com"

CLIENT_ID = "my-client-id"

CLIENT_SECRET = "my-client-secret"

CSV_FILE = "entitlements.csv"






def get_token():

    url = f"{BASE_URL}/oauth/token"


    payload = {

        "grant_type": "client_credentials",

        "client_id": CLIENT_ID,

        "client_secret": CLIENT_SECRET

    }




    response = requests.post(url, data=payload)




    if response.status_code != 200:

        raise Exception(f"Erro ao gerar token: {response.text}")




    return response.json()["access_token"]



def criar_access_profile(linha, token):




    name = linha["name"].strip()

    description = linha["description"].strip() or f"Acesso {linha['name']}"

    source_id = linha["sourceId"]

    entitlement_id = linha["entitlementId"]


    name = name.replace("|", "-")


    payload = json.dumps({

        "name": name,

        "description": description,

        "enabled": True,

        "owner": {

            "type": "IDENTITY",

            "id": "d4ca5a081b154a5d9174578ec0586064",

            "name": "Leticia Ferreira"

        },

        "source": {

            "id": source_id,

            "type": "SOURCE",

            "name": "Active Directory"

        },

        "entitlements": [

            {

            "type": "ENTITLEMENT",

            "id": entitlement_id,

            "name": name

            }

        ],

        "requestable": True,

        "accessRequestConfig": {

            "commentsRequired": True,

            "denialCommentsRequired": True,

            "reauthorizationRequired": True,

            "requireEndDate": True,

            "maxPermittedAccessDuration": {

            "value": 6,

            "timeUnit": "MONTHS"

            },

            "approvalSchemes": [

            {

                "approverType": "GOVERNANCE_GROUP",

                "approverId": "b95932c7-251e-4343-8232-f9acfdcf10eb"

            }

            ]

        },

        "revocationRequestConfig": {

            "approvalSchemes": [

            {

                "approverType": "GOVERNANCE_GROUP",

                "approverId": "b95932c7-251e-4343-8232-f9acfdcf10eb"

            }

            ]

        },

    })




    command = [

        "curl",

        "-s",

        "-X", "POST",

        f"{BASE_URL}/v3/access-profiles",

        "-H", "Content-Type: application/json",

        "-H", f"Authorization: Bearer {token}",

        "-d", payload

    ]




    result = subprocess.run(command, capture_output=True, text=True)




    if result.returncode == 0:

        print(f"✅ Criado: {name}")

        

        if result.stdout:

            print(f"🔎 Response: {result.stdout}")

    else:

        print(f"❌ Erro ao criar {name}: {result.stderr}")



def processar():

    token = get_token()




    with open(CSV_FILE, newline='', encoding='utf-8-sig') as file:

        reader = csv.DictReader(file)


        for linha in reader:

            try:

                criar_access_profile(linha, token)



            except Exception as e:

                print(f"❌ Erro linha {linha}: {str(e)}")



if __name__ == "__main__":

    processar()

Hi @cris-developer

Try removing the “name” field from your owner object in the payload. Name isn’t required and if you set it, it needs to match up perfectly or it will throw a 400 error. I recommend just not including it since this is a create (POST) and not needed.

Before:

        "owner": {

            "type": "IDENTITY",

            "id": "d4ca5a081b154a5d9174578ec0586064",

            "name": "Leticia Ferreira"

        }

After:

        "owner": {

            "type": "IDENTITY",

            "id": "d4ca5a081b154a5d9174578ec0586064"

        }

Hi, @trettkowski

I just tried to follow your advice and i still get the same error

Are you sure are you using identity id of owner? or using account id? Please check on that and also check having any identity errors for the passing owner id

yes im sure, look to the prints bellow

Interesting, looks like your inputs are correct.

You’re using a PAT (Personal Access Token) for your clientid/clientsecret, correct?

ok let us do some new experiment, try this API for creation …/access-profiles/v1

yes, im using client id and secret for PAT.

Also tried this one, the same return.

ok call Get, /identities/id (pass owener id here ) let us know what is response

Also check any id is taken form SandBox but api call you are making prod or also check sourceID entIDs belong to the same tenant you are calling.

for some reason returned a 403 code, but my credetials has all scopes included

You found the root cause now enjoy!

it doesn’t make sense, my credentials already has the scope needed

This actually does, do one thing remove all, just use scope:all

I created a new one just with scope:all
still getting 403

Is your ISC account an ORG_ADMIN?

Yes, my account has administrator permissions

You said you’re using a PAT ( icon in the top right → Preferences → Personal Access Tokens), but in your screenshot you look to be on the API Client page instead for selecting scopes.

API Clients are not PATs. You need a personal access token for most endpoints in ISC as they require an identity to be the creator/modifier for audit/logging.