Having An Issue With Request Body In Powershell SDK

First off, I love the SDK, and I think that the work @tyler_mairose, @colin_mckibben, @christina_gagnon, and gang have done over there is outstanding. However, it is not uncommon for me to run into challenges when using a new cmdlet. This has been the case for the Update-V2025Account cmdlet. I am trying to construct the JSON needed for the request body, and I am just at a loss as to why it is not working. The examples I find use a “here-string” for the JSON body, and I prefer to be a little more structured by creating custom objects and converting them to JSON.
Can someone tell me I am doing wrong?
$orphan = the result from the Get-Accounts cmdlet. It will contain the uncorrellated account.
$identity = result from Search-Post where I find the identity of the person that the $orphan account belongs to.

$operations = @()
$operations += [pscustomobject]@{"op"="replace";"path"="/identityId";"value"=$identity.id}
$operations += [pscustomobject]@{"op"="replace";"path"="/manuallyCorrelated";"value"="true"}
$body = $operations | ConvertTo-Json -AsArray
$result = Update-V2025Account -Id $orphan.id -RequestBody $body

This creates a body of:

[
  {
    "op": "replace",
    "path": "/identityId",
    "value": "7ab852162c684f40a673908b532bab9c"
  },
  {
    "op": "replace",
    "path": "/manuallyCorrelated",
    "value": "true"
  }
]

I have tried it without the “manuallyCorrelated” operation, and I get the same error.

Invoke-WebRequest: C:\Program Files\PowerShell\Modules\PSSailpoint.V2025\1.6.1\Private\V2025ApiClient.ps1:194:25
Line |
 194 |              $Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
     |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     |  {   "detailCode": "400.0 Bad request syntax",   "trackingId": "10a9951f34aa4eb4a7c61600a165b9fd",   "messages": [     {       "locale": "und",       "localeOrigin": "REQUEST",       "text": "The request could
     | not be parsed."     },     {       "locale": "en-US",       "localeOrigin": "DEFAULT",       "text": "The request could not be parsed."     }   ],   "causes": [] }

Any suggestions as to what is wrong with my request body?

My guess is there’s likely nothing wrong with the body but it’s violating the “fine print” of the API functionality. :wink: You can ONLY update accounts that are part of a flat file source.

Note: The attributes field can only be modified for flat file accounts.

Suggestions:

  • Try updating this directly via Postman instead of the SDK to confirm if it works the same way.
  • Turn on the browser developer tools and watch the API calls in the Network tab while doing this via the Web UI to see what API is called and what parameters are passed in the body.

Try making the value of manuallyCorrelated a boolean instead of a string.

I took the same body my code generated and pasted it into the body in Postman and it processed as expected (result code 202)

Powershell values

PS C:\Users> $orphan.id
b76689b3018142cb85c8dfeeb365a330
PS C:\Users> $body
[
  {
    "op": "replace",
    "path": "/identityId",
    "value": "3797f8ac5d2844f5bb60e3ed811d6bb8"
  }
]

So it looks like a problem in the SDK, unless I am looking at this too hard, and I am just not seeing my mistake.

I just tested with the following code block and it works with V2025 (I substituted in your values though in the code). Looking at your example - It looks like the “$body” didn’t get passed as an object, but as a string and that’s the likely difference.

Get-V2025Account b76689b3018142cb85c8dfeeb365a330

$Body = [PSCustomObject]@{
    "op" = "replace"
    "path" = "/identityId"
    "value" = "3797f8ac5d2844f5bb60e3ed811d6bb8"
}

$response = Update-V2025Account -id b76689b3018142cb85c8dfeeb365a330 -RequestBody $Body

I was just coming back to this port to announce that I had figured it out. It is just as you have said. I was converting my object to JSON and passing that string as the RequestBody parameter. If I leave it in its array form, then the call works. It’s just one of those things that can happen when trying to convert between the API documentation and the SDK.

1 Like