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"}
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?
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)
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
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)