For the complete documentation index, see llms.txt. This page is also available as Markdown.

New-PSUApiResponse

Returns a custom API response from a PowerShell Universal REST API.

SYNOPSIS

Returns a custom API response from a PowerShell Universal REST API.

SYNTAX

Body (Default)

New-PSUApiResponse [-StatusCode <Int32>] [-Body <String>] [-Cookies <Hashtable>] [-ContentType <String>]
 [-Headers <Hashtable>] [<CommonParameters>]

Data

New-PSUApiResponse [-StatusCode <Int32>] [-Cookies <Hashtable>] [-Data <Byte[]>] [-ContentType <String>]
 [-Headers <Hashtable>] [<CommonParameters>]

DESCRIPTION

Returns a custom API response from a PowerShell Universal REST API. This cmdlet should be called within the -Endpoint script block defined in New-PSUEndpoint.

EXAMPLES

Example 1

Returns a 404 status code from the /hello endpoint when the GET method is called. This is specifying a custom body as well.

PARAMETERS

-Body

The body of the response to send back from the endpoint request.

-ContentType

The content-type header to set on the response from the endpoint.

-Cookies

A hashtable of cookies to set in the HTTP response.

-Data

Binary data to return from the endpoint. This can be used to send binary files back to the user.

-StatusCode

The HTTP status code to set for this response. The default value is 200.

-Headers

A hashtable of headers to return from the API request.

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction. For more information, see about_CommonParameters.

INPUTS

None

OUTPUTS

System.Object

NOTES

New-PSUEndpoint

Last updated

Was this helpful?