< Back

Invoke-BMRestMethod

Sun Jan 12, 2020 7:11 pm

NAME Invoke-BMRestMethod



SYNOPSIS

Invokes a BuildMaster REST method.





SYNTAX

Invoke-BMRestMethod -Session <Object> -Name <String> [-Method {Default | Get | Head | Post | Put | Delete | Trace

| Options | Merge | Patch}] [-ContentType <String>] [-WhatIf] [-Confirm] [<CommonParameters>]



Invoke-BMRestMethod -Session <Object> -Name <String> [-Method {Default | Get | Head | Post | Put | Delete | Trace

| Options | Merge | Patch}] -Parameter <Hashtable> [-AsJson] [-ContentType <String>] [-WhatIf] [-Confirm]

[<CommonParameters>]



Invoke-BMRestMethod -Session <Object> -Name <String> [-Method {Default | Get | Head | Post | Put | Delete | Trace

| Options | Merge | Patch}] -Body <String> [-ContentType <String>] [-WhatIf] [-Confirm] [<CommonParameters>]





DESCRIPTION

The `Invoke-BMRestMethod` invokes a BuildMaster REST API method. You pass the path to the endpoint (everything

after `/api/`) via the `Name` parameter, the HTTP method to use via the `Method` parameter, and the parameters to

pass in the body of the request via the `Parameter` parameter. This function converts the `Parameter` hashtable

to a URL-encoded query string and sends it in the body of the request. You can send the parameters as JSON by

adding the `AsJson` parameter. You can pass your own custom body to the `Body` parameter. If you do, make sure you

set an appropriate content type for the request with the `ContentType` parameter.



You also need to pass an object that represents the BuildMaster instance and API key to use when connecting via

the `Session` parameter. Use the `New-BMSession` function to create a session object.



When using the `WhatIf` parameter, only web requests that use the `Get` HTTP method are made.





PARAMETERS

-Session <Object>

A session object that represents the BuildMaster instance to use. Use the `New-BMSession` function to create

session objects.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Name <String>

The name of the API to use. The should be everything after `/api/` in the method's URI.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Method

The HTTP/web method to use. The default is `GET`.



Required? false

Position? named

Default value Get

Accept pipeline input? false

Accept wildcard characters? false



-Parameter <Hashtable>

That parameters to pass to the method. These are converted to JSON and sent to the API in the body of the

request.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-AsJson [<SwitchParameter>]

Send the request as JSON. Otherwise, the data is sent as name/value pairs.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Body <String>

The body to send.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ContentType <String>

The content type of the web request.



By default,



* if passing a value to the `Parameter` parameter, the content type is set to

`application/x-www-form-urlencoded`

* if passing a value to the `Parameter` parameter and you're using the `AsJson` switch, the content type is

set to `application/json`.



Otherwise, the content type is not set. If you're passing your own body to the `Body` parameter, you may have

to set the appropriate content type for BuildMaster to respond.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Confirm [<SwitchParameter>]



Required? false

Position? named

Default value

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





RELATED LINKS