I have an API and when I run the PowerShell script:
Invoke-WebRequest 'https://api.tfl.gov.uk/Place/Type/OysterTicketShop'|ConvertFrom-Json
I get the error:
ConvertFrom-Json : Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. Parameter name: input At line:2 char:72 + Invoke-WebRequest 'https://api.tfl.gov.uk/Place/Type/OysterTicketShop'|ConvertFr ... + ~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [ConvertFrom-Json], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand
My understanding is the API is quite large but I haven't been able to resolve the issue.
I tried using:
Invoke-WebRequest 'https://api.tfl.gov.uk/Place/Type/OysterTicketShop'|ConvertFrom-Json
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions")
$jsonserial= New-Object -TypeName System.Web.Script.Serialization.JavaScriptSerializer
$jsonserial.MaxJsonLength = $somevalue
$Obj = $jsonserial.DeserializeObject($rawtext)
$jsonserial.MaxJsonLength = [int]::MaxValue
I still got the same error.