Optimized Aggregation via API

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/loadAccounts/:id

Thanks

Hi @msingh39,

Use Below curl for unoptimized aggregation:

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

Optimized Aggregation:

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

Thanks
Bapu

Hi @msingh39
Please find it here: POST /api/source/loadAccounts

You can use VSCode extension, right click on your source

2 Likes

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: (:slight_smile: [Invoke-RestMethod], ParameterBindingException
    • FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

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

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

  • $response = Invoke-RestMethod 'https://xxxxxxxxidentityNow. …
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Hi,

Use below powershell code lines to execute successfully:

$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

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.

Hi @mahira_majgaonkarpp
try below API it worked for me:

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

Path variable: sourceid
Request body: disableOptimization true

Hi @msingh39,

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

$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
Thank You.

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.

1 Like

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