# Disable Optimization on aggregation / correlation - Does this Python logic look correct?

**URL:** <https://developer.sailpoint.com/discuss/t/disable-optimization-on-aggregation-correlation-does-this-python-logic-look-correct/24323>\
**Category:** SHF Discussion and Questions\
**Tags:** apis, sailpoint-identity-security, aggregation\
**Created:** [January 16, 2024, 5:27pm UTC](https://developer.sailpoint.com/discuss/t/disable-optimization-on-aggregation-correlation-does-this-python-logic-look-correct/24323 "2024-01-16T17:27:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ts\_fpatterson](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/ts_fpatterson/32/26704_2.png) [@ts\_fpatterson](https://developer.sailpoint.com/discuss/u/ts_fpatterson)\
**Post date:** [January 16, 2024, 5:27pm UTC](https://developer.sailpoint.com/discuss/t/disable-optimization-on-aggregation-correlation-does-this-python-logic-look-correct/24323/1 "2024-01-16T17:27:42Z")

</div>

I tried testing this on an AD connector but didn’t find a way to confirm that the setting took place. My lab doesn’t currently have a non-csv based authoritative system.

How do I confirm that aggregation is not optimized on a source?  
Once I do set it on the right source, do I need to remove it afterwards by setting it to false?

Below is an example of code to run, the URL includes the 5 digit source ID.

```auto
import requests
import json

# Connection specific configuration
client_id = ""
client_secret = ""
base_url = f"https://example.api.identitynow.com"
url = f"{base_url}//cc/api/source/loadAccounts/21859"

# 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)

# Payload 
payload = "disableOptimization=true"

headers = {
    'Authorization': f'Bearer {access_token}',
	'Content-Type': 'application/json'
}

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)

```

---

<div class="post-metadata">

**Author:** ![nsorlien](https://avatars.discourse-cdn.com/v4/letter/n/e56c9b/32.png) [@nsorlien](https://developer.sailpoint.com/discuss/u/nsorlien)\
**Post date:** [January 16, 2024, 5:48pm UTC](https://developer.sailpoint.com/discuss/t/disable-optimization-on-aggregation-correlation-does-this-python-logic-look-correct/24323/2 "2024-01-16T17:48:04Z")

</div>

Your request is configured with Content-Type application/json, but your body is not JSON.  
Try using this for your payload instead:

```auto
payload = '{"disableOptimization":true}'

```

You can confirm that it worked by checking that the aggregation entry in the UI contains the following after the aggregation is completed:  
 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/a/ab15ea704e4af2fa455841b4b0d26d4be3603a17.png)

---

<div class="post-metadata">

**Author:** ![ts\_fpatterson](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/ts_fpatterson/32/26704_2.png) [@ts\_fpatterson](https://developer.sailpoint.com/discuss/u/ts_fpatterson)\
**Post date:** [January 16, 2024, 6:18pm UTC](https://developer.sailpoint.com/discuss/t/disable-optimization-on-aggregation-correlation-does-this-python-logic-look-correct/24323/3 "2024-01-16T18:18:40Z")

</div>

I modified the payload line to: `payload = '{"disableOptimization":=true}'`

I don’t get an error, but I still don’t see Optimization as being disabled.

---

<div class="post-metadata">

**Author:** ![nsorlien](https://avatars.discourse-cdn.com/v4/letter/n/e56c9b/32.png) [@nsorlien](https://developer.sailpoint.com/discuss/u/nsorlien)\
**Post date:** [January 16, 2024, 6:53pm UTC](https://developer.sailpoint.com/discuss/t/disable-optimization-on-aggregation-correlation-does-this-python-logic-look-correct/24323/4 "2024-01-16T18:53:56Z")

</div>

You’ll need to remove that `=` and just have the `:` in your payload, if that wasn’t a copy/paste error.

---

<div class="post-metadata">

**Author:** ![ts\_fpatterson](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/ts_fpatterson/32/26704_2.png) [@ts\_fpatterson](https://developer.sailpoint.com/discuss/u/ts_fpatterson)\
**Post date:** [January 16, 2024, 9:30pm UTC](https://developer.sailpoint.com/discuss/t/disable-optimization-on-aggregation-correlation-does-this-python-logic-look-correct/24323/5 "2024-01-16T21:30:16Z")

</div>

Thanks Nathan! That worked.

Any ideas on why manager correlation would not have worked? We didn’t actually change a value, but the manager didn’t correlate. All other managers correlated previously.

do we actually have to change the manager id in the source in order for correlations to work?

---

<div class="post-metadata">

**Author:** ![nsorlien](https://avatars.discourse-cdn.com/v4/letter/n/e56c9b/32.png) [@nsorlien](https://developer.sailpoint.com/discuss/u/nsorlien)\
**Post date:** [January 16, 2024, 10:17pm UTC](https://developer.sailpoint.com/discuss/t/disable-optimization-on-aggregation-correlation-does-this-python-logic-look-correct/24323/6 "2024-01-16T22:17:15Z")

</div>

I haven’t had any issues with manager correlation in the past, but I frequently use optimization disabled aggregations to reevaluate account correlation. You could try this on your authoritative source to see if it reevaluates manager correlation.

---

<div class="post-metadata">

**Author:** ![ts\_fpatterson](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/ts_fpatterson/32/26704_2.png) [@ts\_fpatterson](https://developer.sailpoint.com/discuss/u/ts_fpatterson)\
**Post date:** [January 16, 2024, 10:21pm UTC](https://developer.sailpoint.com/discuss/t/disable-optimization-on-aggregation-correlation-does-this-python-logic-look-correct/24323/7 "2024-01-16T22:21:20Z")

</div>

Yeah, I was hoping it would fix it.

I have a few users that wouldn’t correlate. My assumption is that the manager employee ID was possibly populated before the manager was populated in the system. The manager went from a contractor to an employee.

It looks like if the correlation doesn’t work, it will keep a null value or the same manager they had. Currently my only thought is that if it requires a change for HR to change them to a different manager, aggregate and then change them back and aggregate again.

As it is not a delimited text connector, I don’t see a way to change the manager ID value through API on the source account value within IDN.

---

<div class="post-metadata">

**Author:** ![davepeters](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@davepeters](https://developer.sailpoint.com/discuss/u/davepeters)\
**Post date:** [January 28, 2024, 4:42pm UTC](https://developer.sailpoint.com/discuss/t/disable-optimization-on-aggregation-correlation-does-this-python-logic-look-correct/24323/8 "2024-01-28T16:42:33Z")

</div>

Hi Fred, You might be interested in this python library:

> **[GitHub - fitchgroup/sailpoint: The aim of this project is to allow for an...](https://github.com/fitchgroup/sailpoint)**
>
> The aim of this project is to allow for an easy and fast way to build python scripts for common implementation and administration tasks needed when working with SailPoint IdentityNow. - GitHub - fi...

If you have questions, email the author, and I will be happy to respond. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [March 28, 2024, 4:42pm UTC](https://developer.sailpoint.com/discuss/t/disable-optimization-on-aggregation-correlation-does-this-python-logic-look-correct/24323/9 "2024-03-28T16:42:47Z")

</div>

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