# Optimized Aggregation via API

**URL:** <https://developer.sailpoint.com/discuss/t/optimized-aggregation-via-api/89131>\
**Category:** SHF Discussion and Questions\
**Tags:** isc-questions-and-answers, sailpoint-identity-security, aggregation\
**Created:** [November 11, 2024, 9:56am UTC](https://developer.sailpoint.com/discuss/t/optimized-aggregation-via-api/89131 "2024-11-11T09:56:01Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![msingh39](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@msingh39](https://developer.sailpoint.com/discuss/u/msingh39)\
**Post date:** [November 11, 2024, 9:56am UTC](https://developer.sailpoint.com/discuss/t/optimized-aggregation-via-api/89131/1 "2024-11-11T09:56:01Z")

</div>

Hi Folks,

Anyone knows how to execute Optimized Aggregation via API?

I am trying below one’s but it seems outdated and not in use. Any alternative?

[https://uxxxxxx.com/api/source/:id/loadAccounts](https://uxxxxxx.com/api/source/:id/loadAccounts)  
[https://uxxxxxx.com/api/source/loadAccounts/:id](https://uxxxxxx.com/api/source/loadAccounts/:id)

Thanks

---

<div class="post-metadata">

**Author:** ![gogubapu](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/gogubapu/32/15242_2.png) [@gogubapu](https://developer.sailpoint.com/discuss/u/gogubapu)\
**Post date:** [November 11, 2024, 10:07am UTC](https://developer.sailpoint.com/discuss/t/optimized-aggregation-via-api/89131/2 "2024-11-11T10:07:13Z")

</div>

Hi @msingh39,

Use Below curl for unoptimized aggregation:

```auto
curl --location --request POST 'https://{{tenant}}.api.identitynow-demo.com/beta/sources/{{SourceId}}/load-accounts' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsIn' \
--form 'disableOptimization="true"'

```

Optimized Aggregation:

```auto
curl --location --request POST 'https://{{tenant}}.api.identitynow-demo.com/beta/sources/{{SourceId}}/load-accounts' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsIn' \
--form 'disableOptimization="false"'

```

Thanks  
Bapu

---

<div class="post-metadata">

**Author:** ![gourab](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/gourab/32/18650_2.png) [@gourab](https://developer.sailpoint.com/discuss/u/gourab)\
**Post date:** [November 11, 2024, 10:30am UTC](https://developer.sailpoint.com/discuss/t/optimized-aggregation-via-api/89131/3 "2024-11-11T10:30:30Z")

</div>

Hi @msingh39  
Please find it here: [POST /api/source/loadAccounts](https://developer.sailpoint.com/discuss/t/post-api-source-loadaccounts/20515)

---

<div class="post-metadata">

**Author:** ![KRM7](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/krm7/32/2685_2.png) [@KRM7](https://developer.sailpoint.com/discuss/u/KRM7)\
**Post date:** [November 11, 2024, 10:31am UTC](https://developer.sailpoint.com/discuss/t/optimized-aggregation-via-api/89131/4 "2024-11-11T10:31:13Z")

</div>

> **[import-accounts | SailPoint Developer Community](https://developer.sailpoint.com/docs/api/beta/import-accounts)**
>
> \<Heading

You can use VSCode extension, right click on your source

 ![image](https://global.discourse-cdn.com/sailpoint/original/3X/e/2/e2266ee33a751377b92cb5c8fc3a4bb63d10210b.png)

---

<div class="post-metadata">

**Author:** ![msingh39](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@msingh39](https://developer.sailpoint.com/discuss/u/msingh39)\
**Post date:** [November 11, 2024, 11:34am UTC](https://developer.sailpoint.com/discuss/t/optimized-aggregation-via-api/89131/5 "2024-11-11T11:34:50Z")

</div>

Thanks for the response. I tried it and got below error:-

Invoke-RestMethod : A parameter cannot be found that matches parameter name ‘form’.

- … 0fea1225/load-accounts’ -Method ‘GET’ -Headers $headers -form 'disabl …
- 

```
                                                        ~~~~~

```

  - CategoryInfo : InvalidArgument: (🙂 [Invoke-RestMethod], ParameterBindingException
  - FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

---

<div class="post-metadata">

**Author:** ![msingh39](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@msingh39](https://developer.sailpoint.com/discuss/u/msingh39)\
**Post date:** [November 11, 2024, 11:38am UTC](https://developer.sailpoint.com/discuss/t/optimized-aggregation-via-api/89131/6 "2024-11-11T11:38:39Z")

</div>

I also got below error after removing “-Form” :-

Invoke-RestMethod : {“error”:“No message available”}

- $response = Invoke-RestMethod '[https://xxxxxxxxidentityNow](https://xxxxxxxxidentityNow). …
- 

```
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

```

  - CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
  - FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

---

<div class="post-metadata">

**Author:** ![gogubapu](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/gogubapu/32/15242_2.png) [@gogubapu](https://developer.sailpoint.com/discuss/u/gogubapu)\
**Post date:** [November 11, 2024, 11:43am UTC](https://developer.sailpoint.com/discuss/t/optimized-aggregation-via-api/89131/7 "2024-11-11T11:43:29Z")

</div>

Hi,

Use below powershell code lines to execute successfully:

```auto
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "multipart/form-data")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer <TOKEN>")

$multipartContent = [System.Net.Http.MultipartFormDataContent]::new()
$stringHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$stringHeader.Name = "disableOptimization"
$stringContent = [System.Net.Http.StringContent]::new("true")
$stringContent.Headers.ContentDisposition = $stringHeader
$multipartContent.Add($stringContent)

$body = $multipartContent

$response = Invoke-RestMethod 'https://sailpoint.api.identitynow.com/v2024/sources/:id/load-accounts' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

```

Thanks  
Bapu

---

<div class="post-metadata">

**Author:** ![lukas\_ceremeta](https://avatars.discourse-cdn.com/v4/letter/l/8baadc/32.png) [@lukas\_ceremeta](https://developer.sailpoint.com/discuss/u/lukas_ceremeta)\
**Post date:** [November 11, 2024, 11:47am UTC](https://developer.sailpoint.com/discuss/t/optimized-aggregation-via-api/89131/8 "2024-11-11T11:47:43Z")

</div>

Powershell 5.1 does not support -Form parameter for invoke-restmethod.  
Either install Powershell 7, use C# objects or use CURL. Curl is built in into windows 10+. CURL was added to Windows 10 (1803) and later.

 ![image](https://global.discourse-cdn.com/sailpoint/original/3X/6/1/61bc805ea99c494372014a054d9c8d115e383108.png)

---

<div class="post-metadata">

**Author:** ![sagar\_kamalakar](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/sagar_kamalakar/32/18893_2.png) [@sagar\_kamalakar](https://developer.sailpoint.com/discuss/u/sagar_kamalakar)\
**Post date:** [November 12, 2024, 4:39am UTC](https://developer.sailpoint.com/discuss/t/optimized-aggregation-via-api/89131/9 "2024-11-12T04:39:30Z")

</div>

Hi @mahira_majgaonkarpp  
try below API it worked for me:

POST ## [https://sailpoint.api.identitynow.com/beta/sources/:id/load-accounts](https://sailpoint.api.identitynow.com/beta/sources/:id/load-accounts)

Path variable: sourceid  
Request body: disableOptimization true

---

<div class="post-metadata">

**Author:** ![gogubapu](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/gogubapu/32/15242_2.png) [@gogubapu](https://developer.sailpoint.com/discuss/u/gogubapu)\
**Post date:** [November 12, 2024, 5:02am UTC](https://developer.sailpoint.com/discuss/t/optimized-aggregation-via-api/89131/10 "2024-11-12T05:02:49Z")

</div>

Hi @msingh39,

I have tested below PowerShell script, it is working as expected:

```auto
$bearerToken = "hLTExNjUwIiwiaWRlbnRpdHlfaWQiOiIzMWUwZDU1OGY3ZmY0M2Y5OGJiOTQyNzk3YTg3ODhmNCIsInVzZXJfbmFtZSI6ImJhcHUuZ29ndSIsInNjb3BlIjpbIkJnQUFBQUFBQUFRPSJdLCJzdHJvbmdfYXV0aCI6dHJ1ZSwiZXhwIjoxNzMxNDI4NTI4LCJhdX"
# Run optimized or UnOptimized Aggregation using below
$header = @{
    "Authorization" = "Bearer $bearerToken"
}

$body = @{
"disableOptimization" = "false"
}

$response = Invoke-RestMethod -Method Post ` -Uri "https://tenant-sb.api.identitynow-demo.com/beta/sources/118e606ed9ee4ee7ab70b6f70ad2aa5f/load-accounts" ` -Headers $header -Body $body

echo $response

```

Click on below link for more details : [import-accounts | SailPoint Developer Community](https://developer.sailpoint.com/docs/api/beta/import-accounts)  
Thank You.

---

<div class="post-metadata">

**Author:** ![KRM7](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/krm7/32/2685_2.png) [@KRM7](https://developer.sailpoint.com/discuss/u/KRM7)\
**Post date:** [November 12, 2024, 8:46am UTC](https://developer.sailpoint.com/discuss/t/optimized-aggregation-via-api/89131/11 "2024-11-12T08:46:42Z")

</div>

I don’t think @msingh39 is looking for a script to aggregate to do some customizations, believe he is just looking for running aggregation through API, this is quite normal, we do run lot of API calls in our day to day activities.

Do we really need some scripting, why are you complicating this ?

Make it simple, either use API in Postman or use VSCode extension. Make your life easier.

---

<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:** [January 11, 2025, 8:47am UTC](https://developer.sailpoint.com/discuss/t/optimized-aggregation-via-api/89131/12 "2025-01-11T08:47:39Z")

</div>

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