V3/accounts API sometimes returns string and sometimes returns JSON

Depending on which account is retrieved the v3 API to retrieve accounts will sometimes return nicely formatted JSON object and sometimes it will retrieve a giant string. It’s the same API call though, just a different offset in the URI. Also if any of the accounts that I’ve had trouble with are bundled in a large call with accounts that are fine on their own then it corrupts the entire response by returning one gigantic string.

I’m using Invoke-RestMethod.

@crderosier when you get response form Invoke-Rest method, try using ConvertTo-json cmdlet to always convert the data into json format.

you can use
Response | Select-Object -Property * | ConvertTo-Json - depth 32

Reference : ConvertTo-Json (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn

Let me know if this helps or you still face error.

Thanks,
Vaibhav

1 Like

Yep we’re already doing that unfortunately. It’s still returning a string when certain accounts are retrieved.

@crderosier

You mention certain accounts. Is there anything about the data for these accounts that is different than other accounts like use of special characters in their data?

Alicia

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