Invoke-RestMethod
.New-PSUEndpoint
call as it will be defined by the admin console. :
). 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.param
block to ensure that only valid parameters are provided to the endpoint. $IsChallengePassed
query string parameter could be included to bypass the challenge. param
block. $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./get/:id
endpoint, we could have comment-based help such as this. -PersistentRunspace
parameter to enable this feature. This is configured in the environments.ps1
script.settings.ps1
script.New-PSUEndpoint
-Timeout
parameter. The timeout is set in the number of seconds. -Path
parameter of New-PSUEndpoint
. The path is relative to the Repository directory. For example, the file layout would appear like this. endpoints.ps1
file is then this.