Disable optimize aggregation from a source

It appears that the cc api to disable the optimization on an aggregation has been removed. I believe I received a 401 error.

I tried updating my logic to use the v2024 api, but it is failing with a 500 error.

Any ideas on what is wrong with my python script?

import requests
import getpass

# Prompt the user to enter the necessary variables
print("Trigger an aggregation for a source with optimization disabled.")
client_id = input("Please enter your client ID: ")
client_secret = getpass.getpass("Please enter your client secret: ")
client = input("Please enter your tenant name (example: acme-sb is what you would enter if the full URL is https://acme-sb.identitynow.com): ")
base_url = f"https://{client}.api.identitynow.com"
source = input("Please enter the Source ID the source you need to aggregate.")
url = f"{base_url}/v2024/sources/{source}/loadAccounts"

# Get an access token
auth_url = f"{base_url}/oauth/token"
auth_data = {
    "grant_type": "client_credentials",
    "client_id": client_id,
    "client_secret": client_secret,
}
auth_response = requests.post(auth_url, data=auth_data)
print(auth_response)

# Extract the access token from the response
access_token = auth_response.json()["access_token"]
#print(access_token)


headers = {
    'Authorization': f'Bearer {access_token}',
    'Accept': 'application/json',
    'Content-Type': 'multipart/form-data',
    'X-SailPoint-Experimental': 'true'
}

payload = '{"disableOptimization": true}'

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

if response.status_code == 200:
    data = response.json()
  
else:
    print(f"Request for sources failed with status code: {response.status_code}")
    print("Response content:", response.text)
    

error was

Trigger an aggregation for a source with optimization disabled.
<Response [200]>
Request for sources failed with status code: 500
Response content: {"messages":[{"localeOrigin":"REQUEST","text":"An internal fault occurred.","locale":"en-US"},{"localeOrigin":"DEFAULT","text":"An internal fault occurred.","locale":"en-US"}],"trackingId":"2c9b753f36464d0c890823093b9c065b","detailCode":"500.0 Internal fault"}

Hey Fred,

It looks like that endpoint should be /v2024/sources/:id/load-accounts. Note the hyphen between ā€˜loadā€™ and ā€˜accountsā€™, which I donā€™t see in your code. Can you try adding this and see if it resolves the issue?

Thank you,

  • Zach
1 Like

thanks, I did correct that and still see the same error.

I updated the headers with removing the experimental line, and a few of the others to see if it would change anything, but any change I made still gives the 500 error.

I get a 200 on the authentication, but always the 500 after.

Current logic Iā€™m using is:

import requests
import getpass

# Prompt the user to enter the necessary variables
print("Trigger an aggregation for a source with optimization disabled.")
client_id = input("Please enter your client ID: ")
client_secret = getpass.getpass("Please enter your client secret: ")
client = input("Please enter your tenant name (example: acme-sb is what you would enter if the full URL is https://acme-sb.identitynow.com): ")
base_url = f"https://{client}.api.identitynow.com"
source = input("Please enter the Source ID the source you need to aggregate.")
url = f"{base_url}/v2024/sources/{source}/load-accounts"

# Get an access token
auth_url = f"{base_url}/oauth/token"
auth_data = {
    "grant_type": "client_credentials",
    "client_id": client_id,
    "client_secret": client_secret,
}
auth_response = requests.post(auth_url, data=auth_data)
print(auth_response)

# Extract the access token from the response
access_token = auth_response.json()["access_token"]
#print(access_token)


headers = {
    'Authorization': f'Bearer {access_token}',
    'Accept': 'application/json',
    'Content-Type': 'multipart/form-data',
    'X-SailPoint-Experimental': 'true'
}

payload = '{"disableOptimization": true}'

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


if response.status_code == 200:
    data = response.json()
  
else:
    print(f"Request for sources failed with status code: {response.status_code}")
    print("Response content:", response.text)
    

1 Like

Did you try removing this header: ā€˜Content-Typeā€™: ā€˜multipart/form-dataā€™?

I believe that is only required for aggregating delimited file sources.

Thank you,

  • Zach
1 Like

Alternatively, if you are trying to aggregate a delimited file source, you can leave that header and include the file in the request body.

1 Like

Hi Fred,

Could you try updating your payload line to the below format:

payload = {'disableOptimization': 'true'}

Thanks,

Liam

1 Like

Try this from Colin a few weeks ago and see if this helps.

curl -L 'https://sailpoint.api.identitynow.com/beta/sources/:id/load-accounts' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
-d 'disableOptimization=true'
1 Like

@ts_fpatterson

I see that you are using v2024 experimental APIā€™s and there i do not see application/x-www-form-urlencoded as the content type listed. But when i look at beta apiā€™s its listed over there so maybe you can change the API endpoint to beta

https://{{tenant}}.api.identitynow.com/beta/sources/:id/load-accounts

The Content-Type should be ā€œapplication/x-www-form-urlencodedā€ if it is connected source.
In case of CSV, it should be ā€œmultipart/form-dataā€

Hope this helpsā€¦

1 Like

Thanks for all of the help.

I was able to get the Python code working using the beta api and fixing the content-Type as well as fixing the payload.

Feel free to use this logic

import requests
import getpass

# Prompt the user to enter the necessary variables
print("Trigger an aggregation for a source with optimization disabled.")
client_id = input("Please enter your client ID: ")
client_secret = getpass.getpass("Please enter your client secret: ")
client = input("Please enter your tenant name (example: acme-sb is what you would enter if the full URL is https://acme-sb.identitynow.com): ")
base_url = f"https://{client}.api.identitynow.com"
source = input("Please enter the Source ID the source you need to aggregate.")
url = f"{base_url}/beta/sources/{source}/load-accounts"

# Get an access token
auth_url = f"{base_url}/oauth/token"
auth_data = {
    "grant_type": "client_credentials",
    "client_id": client_id,
    "client_secret": client_secret,
}
auth_response = requests.post(auth_url, data=auth_data)
print(auth_response)

# Extract the access token from the response
access_token = auth_response.json()["access_token"]
#print(access_token)


headers = {
    'Authorization': f'Bearer {access_token}',
    'Accept': 'application/json',
    'Content-Type': 'application/x-www-form-urlencoded'
}

payload = {"disableOptimization": True}

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


if response.status_code == 200:
    data = response.json()
  
else:
    print(f"Request for sources failed with status code: {response.status_code}")
    print("Response content:", response.text)
    

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.