< Back

Invoke-NsxRestMethod

Sat Jan 18, 2020 9:14 pm

NAME Invoke-NsxRestMethod



SYNOPSIS

Constructs and performs a valid NSX REST call. This function is DEPRECATED

Use Invoke-NsxWebRequest for all new functions.





SYNTAX

Invoke-NsxRestMethod [-method <String>] [-URI <String>] [-body <String>] [-connection <PSObject>] [-extraheader

<Hashtable>] [-Timeout <Int32>] [<CommonParameters>]



Invoke-NsxRestMethod -cred <PSCredential> -server <String> -port <Int32> -protocol <String> -UriPrefix <String>

-ValidateCertificate <Boolean> -method <String> -URI <String> [-body <String>] [<CommonParameters>]





DESCRIPTION

Invoke-NsxRestMethod uses either a specified connection object as returned

by Connect-NsxServer, or the $DefaultNsxConnection global variable if

defined to construct a REST api call to the NSX API.



Invoke-NsxRestMethod constructs the appropriate request headers required by

the NSX API, including authentication details (built from the connection

object), required content type and includes any custom headers specified by

the caller that might be required by a specific API resource, before making

the rest call and returning the appropriate XML object to the caller.





PARAMETERS

-cred <PSCredential>

PSCredential object containing authentication details to be used for connection to NSX Manager API



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-server <String>

NSX Manager ip address or FQDN



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-port <Int32>

TCP Port on -server to connect to



Required? true

Position? named

Default value 0

Accept pipeline input? false

Accept wildcard characters? false



-protocol <String>

Protocol - HTTP/HTTPS



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-UriPrefix <String>

URI Prefix to support URI rewrite scenario



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ValidateCertificate <Boolean>

Validates the certificate presented by NSX Manager for HTTPS connections



Required? true

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-method <String>

REST method of call. Get, Put, Post, Delete, Patch etc



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-URI <String>

URI of resource (/api/1.0/myresource). Should not include protocol, server or port.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-body <String>

Content to be sent to server when method is Put/Post/Patch



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-connection <PSObject>

Pre-populated connection object as returned by Connect-NsxServer



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-extraheader <Hashtable>

Hashtable collection of KV pairs representing additional headers to send to the NSX Manager during REST call



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Timeout <Int32>

Request timeout value - passed directly to underlying invoke-restmethod call



Required? false

Position? named

Default value 600

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Invoke-NsxRestMethod -Method get -Uri "/api/2.0/vdn/scopes"



Performs a 'Get' against the URI /api/2.0/vdn/scopes and returns the xml

object respresenting the NSX API XML reponse. This call requires the

$DefaultNsxServer variable to exist and be populated with server and

authentiation details as created by Connect-NsxServer -DefaultConnection









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>$MyConnection = Connect-NsxServer -Server OtherNsxManager -DefaultConnection:$false



Invoke-NsxRestMethod -Method get -Uri "/api/2.0/vdn/scopes" -connection $MyConnection



Creates a connection variable for a non default NSX server, performs a

'Get' against the URI /api/2.0/vdn/scopes and returns the xml

object respresenting the NSX API XML reponse.











RELATED LINKS