< Back

Invoke-NRRequest

Sat Jan 18, 2020 5:05 pm

NAME Invoke-NRRequest



SYNOPSIS

Builds up and submits a web request to the New Relic API.





SYNTAX

Invoke-NRRequest -ApiKey <String> -Uri <Uri> -Method <String> [-Body <Hashtable>] [<CommonParameters>]



Invoke-NRRequest -QueryKey <String> -Uri <Uri> -Method <String> [-Body <Hashtable>] [<CommonParameters>]



Invoke-NRRequest -InsertKey <String> -Uri <Uri> -Method <String> [-Body <Hashtable>] [<CommonParameters>]





DESCRIPTION

Will build a properly structured web request to use for the New Relic API. This is mostly used by other

cmdlets and is meant to be generic, thus it will not form the body or URI needed for most requests.





PARAMETERS

-ApiKey <String>

Api key for connecting to New Relic. Go to the link below for more details:

https://docs.newrelic.com/docs/apis/res ... s/api-keys



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-QueryKey <String>

Query key for running queries against Insights



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-InsertKey <String>

Insert key for posting events to Insights



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Uri <Uri>

Uri for the request being made



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Method <String>

Method to be used for the request



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Body <Hashtable>

Extra data to be sent with the request



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

System.Management.Automation.PSCustomObject

The object returned is the content block (converted from json) from the web request response.





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



PS C:\\>Invoke-NRRequest -ApiKey '1234abc' -Uri 'https://newrelic.com/someuri' -Method 'Get'



# This is a basic get request against https://newrelic.com/someuri, with no body.









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



PS C:\\>Invoke-NRRequest -ApiKey '1234abc' -Uri 'https://newrelic.com/someuri' -Method 'Post' -Body "{'Name' =

'Value'}"



# This is a post request against 'https://newrelic.com/someuri' including the body parameter.











RELATED LINKS