Invoke-FabricRestMethod
Sends an HTTP request to a Fabric or Power BI API endpoint and retrieve the response.
Syntax
Invoke-FabricRestMethod [-Uri] <string> [[-Method] <string>] [[-Body] <Object>] [[-Timeout] <int>]
[[-RequestTimeoutSeconds] <int>] [[-ExtractValue] <string>] [[-TypeName] <string>]
[[-ObjectIdOrName] <string>] [[-SuccessMessage] <string>] [-TestTokenExpired] [-PowerBIApi]
[-NoWait] [-HandleResponse] [<CommonParameters>]Description
Sends an HTTP request to a Fabric or Power BI API endpoint and retrieve the response. Supports pagination by recognizing continuation tokens in the response. Supports handling of long-running operations and throttling (error 429) responses. Facilitates both synchronous and asynchronous operations. Message logging is provided for debugging and informational purposes.
Examples
Example 1
Invoke-FabricRestMethod -uri "workspaces" -method "GET"This example sends a GET request to the "https://api.fabric.microsoft.com/v1/workspaces" endpoint of the Fabric API.
Example 2
Invoke-FabricRestMethod -uri "/api/resource" -method "POST" -body $requestBodyThis example sends a POST request to the "/api/resource" endpoint of the Fabric API with a request body.
Parameters
| Name | Type | Req. | Pos. | Pipeline | Description |
|---|---|---|---|---|---|
| -Uri | string | ✓Required | 0 | – | The URI of the Fabric API endpoint to send the request to. Can be a relative path (e.g., "workspaces") or a full URL (e.g., "https://api.fabric.microsoft.com/v1/workspaces"). |
| -Body | object | 2 | – | The body of the request, if applicable. This can be a hashtable or a string. If a hashtable is provided, it will be converted to JSON format. |
|
| -ExtractValue | string | 5 | – | A string parameter to specify whether to extract the 'value' property from the response. Valid values are 'True', 'False', and 'Auto'. The default is 'False'. 'Auto' will extract 'value' if it exists in the response. |
|
| -HandleResponse | switch | Named | – | A switch parameter to indicate that the response should be handled after call API. Default is False. The operation will be processed based on the response status code and supports Throttling (429) and Long-Running Operations. Default: True |
|
| -Method | string | 1 | – | The HTTP method to be used for the request. Valid values are 'GET', 'POST', 'DELETE', 'PUT', and 'PATCH'. The default value is 'GET'. Default: GET |
|
| -NoWait | switch | Named | – | A switch parameter to indicate that the function should not wait for the response. This is useful for asynchronous operations. Default is False. If set to True, the function will return immediately without waiting for the operation to complete. Default: False |
|
| -ObjectIdOrName | string | 7 | – | Optional. The name or ID of the resource being operated on. This is used for logging purposes. Should be used when |
|
| -PowerBIApi | switch | Named | – | A switch parameter to indicate that the request should be sent to the Power BI API instead of the Fabric API. Default: False |
|
| -RequestTimeoutSeconds | int | 4 | – | An internal request timeout, in seconds, used to keep long-running operation status requests within the remaining timeout budget. Default: 0 |
|
| -SuccessMessage | string | 8 | – | Optional. A message to log upon successful completion of the operation. This is used for logging purposes. Should be used when |
|
| -TestTokenExpired | switch | Named | – | A switch parameter to test if the Fabric token is expired before making the request. If the token is expired, it will attempt to refresh it. Default is False. If set to True, the function will check the token state before making the request. Default: False |
|
| -Timeout | int | 3 | – | The maximum time, in minutes, to wait for a long-running operation. A value of 0 waits indefinitely. Default: 0 |
|
| -TypeName | string | 6 | – | Optional. The type of resource being operated on. This is used for logging purposes. Default is 'Fabric Item'. Should be used when Default: Fabric Item |
This cmdlet also supports the common parameters, such as -Verbose and -ErrorAction. See about_CommonParameters.
Notes
- Requires
$FabricConfigglobal configuration, includingBaseUrl.
Author: Kamil Nowinski