Powershell ISE vs Powershell.exe

Hi Guys,

Just got this error, I just removed the trackingid. what we are using is the V3/Search in PowerShell ISE and PowerShell.exe

Invoke-RestMethod : {“detailCode”:“400.1.3 Illegal value”,“trackingId”:" 123456",“messages”:[{“locale”:“en-US”,“localeOrigin”:“DEFAULT”,“text”:"Illegal value

I am trying to convert this query into strings

From:

$query = @"
{“query”:{“query”:"(@accounts(source.name:\“Sailpoint\”) AND created: [now-72h TO now]) OR (@accounts(source.name:\“Sailpoint\”) AND attributes.startDate:[2024-04-02 TO 2024-04-12]"},"indices":["identities"],"includeNested":false,"sort":[“displayName`”]}
"@

To:

$body = @"
{"query":{"query":"(@accounts(source.name:"', $source, '") AND created: [now-', $duration, 'h TO now]) OR (@accounts(source.name:"', $source, '") AND attributes.startDate:[', $dateNow, ' TO ', $dateLater, '])“},"indices”:["identities"],"includeNested":false,"sort":["displayName"]}
"@

$response = Invoke-RestMethod ‘https:/sailpoint.api.identitynow.com/v3/search/’ -Method ‘POST’ -Headers $headers -Body $query
$response | ConvertTo-Json

Not sure if this is the same issue as this one