Is there a standard way to use Invoke-WebRequest or Invoke-RestMethod in PowerShell to retrieve information from a web page using a query string?
For example, I know that the following when used with a well-formed JSON endpoint will work:
$Parameters = @{
Name = 'John'
Children = 'Abe','Karen','Jo'
}
$Result = Invoke-WebRequest -Uri 'http://.....whatever' -Body ( $Parameters | ConvertTo-Json) -ContentType application/json -Method Get
along with the equivalent Invoke-WebMethod. An important aspect of this is the content type and ConvertTo-JSON, which controls the conversion of the parameters specified in the -Body part to a standard form, including the array field aspect of the Children field.
What is the equivalent way to do this using a website that uses, for example, a comma-delimited convention to control array arguments in a URL or an approach such as "Children [] = Abe & Children [] = Karen & Children = Joe "?
Is there a type of content that I am missing and is there an equivalent to ConvertTo- ?? what can i use? I guess someone should have done this before.
In context, this often uses a method of encoding an array parameter in a URL and is commonly seen on PHP websites.
passing arrays as a URL parameter
Edit
Removed links to PHP except for a specific context and adjusted the header for links to the query string. The problem is encoding the query string, not PHP as such.