Invoke-RestMethod
.:
). For example, the following URL would provide a variable for the ID of the user. The $Id
variable will be defined within the endpoint when it is executed. Variables must be unique in the same endpoint URL.$Id
variable, it could be provided via the query string.Invoke-RestMethod
call must then include the query string parameter.$Body
variable. Universal $Body
variable will be a string. If you expect JSON, you should use ConvertFrom-Json
.Invoke-RestMethod
.param
block within your script to enforce mandatory parameters and provide default values for optional parameters such as query string parameters. Variables such as $Body
, $Headers
and $User
are provided automatically.$Name
parameter is mandatory and the $Role
parameter has a default value of Default.$Data
parameter to access the byte array of data uploaded to the endpoint.New-PSUApiResponse
cmdlet.New-PSUApiResponse
cmdlet in your endpoint. This cmdlet allows you to set the status code, content type and even specify the byte[] data for the content to be returned.-Body
parameter of New-PSUApiResponse
.-ContentType
parameter.-PersistentRunspace
parameter to enable this feature. This is configured in the environments.ps1
script.settings.ps1
script.