Skip to content

Latest commit

 

History

History
223 lines (170 loc) · 5.01 KB

File metadata and controls

223 lines (170 loc) · 5.01 KB
external help file Module Name online version schema
Rnwood.Dataverse.Data.PowerShell.FrameworkSpecific.dll-Help.xml
Rnwood.Dataverse.Data.PowerShell
2.0.0

Invoke-DataverseRequest

SYNOPSIS

Invokes an arbitrary Dataverse request and returns the response.

SYNTAX

Request

Invoke-DataverseRequest -Connection <ServiceClient> -Request <OrganizationRequest>
 [-ProgressAction <ActionPreference>] [<CommonParameters>]

NameAndInputs

Invoke-DataverseRequest -Connection <ServiceClient> -RequestName <String> [-Parameters <Hashtable>]
 [-ProgressAction <ActionPreference>] [<CommonParameters>]

REST

Invoke-DataverseRequest -Connection <ServiceClient> -Method <HttpMethod> -Path <String> [-Body <PSObject>]
 [-CustomHeaders <Hashtable>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

EXAMPLES

Example 1

PS C:\> $request = new-object Microsoft.Crm.Sdk.Messages.WhoAmIRequest
PS C:\> $response = Invoke-DataverseRequest -connection $c -request $request

Invokes WhoAmIRequest using the type from the Dataverse SDK using existing connection $c and storing the response into a variable.

Example 2

PS C:\> $request = new-object Microsoft.Xrm.Sdk.OrganizationRequest "myapi_EscalateCase"
PS C:\> $request["Target"] = new-object Microsoft.Xrm.Sdk.EntityReference "incident", "{DC66FE5D-B854-4F9D-BA63-4CEA4257A8E9}"
PS C:\> $request["Priority"] = new-object Microsoft.Xrm.Sdk.OptionSetValue 1
PS C:\> $response = Invoke-DataverseRequest -connection $c -request $request

Invokes myapi_EscalateCase using without using a request type from the Dataverse SDK using existing connection $c and storing the response into a variable.

Example 3

PS C:\> $Target = new-object Microsoft.Xrm.Sdk.EntityReference "incident", "{DC66FE5D-B854-4F9D-BA63-4CEA4257A8E9}"
PS C:\> $Priority = new-object Microsoft.Xrm.Sdk.OptionSetValue 1
PS C:\> $response = Invoke-DataverseRequest -connection $c myapi_EscalateCase @{"Target"=$Target; "Priority=$Priority}

Invokes myapi_EscalateCase by using just the request name and parameters using existing connection $c and storing the response into a variable.

Example 4

PS C:\>invoke-dataverserequest -connection $c -method POST myapi_Example -CustomHeaders @{"foo"="bar"} -Body @{"a"=1; "b"=3}

Invokes the GET myapi_Example REST API using custom headers and body

PARAMETERS

-Connection

DataverseConnection instance obtained from Get-DataverseConnnection cmdlet

Type: ServiceClient
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Request

Request to execute using the OrganizationRequest class or subclass from the SDK.

See https://learn.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.organizationrequest?view=dataverse-sdk-latest

Type: OrganizationRequest
Parameter Sets: Request
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-ProgressAction

See standard PS docs.

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Parameters

{{ Fill Parameters Description }}

Type: Hashtable
Parameter Sets: NameAndInputs
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-RequestName

{{ Fill RequestName Description }}

Type: String
Parameter Sets: NameAndInputs
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Body

{{ Fill Body Description }}

Type: PSObject
Parameter Sets: REST
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Method

{{ Fill Method Description }}

Type: HttpMethod
Parameter Sets: REST
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Path

{{ Fill Path Description }}

Type: String
Parameter Sets: REST
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-CustomHeaders

{{ Fill CustomHeaders Description }}

Type: Hashtable
Parameter Sets: REST
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

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

INPUTS

OUTPUTS

NOTES

RELATED LINKS