Error: The List Flows as Admin API is no longer supported. Please use the List Flows as Admin (V2) API.
Priority
(Urgent) I can't use the CLI
Description
I am using the m365 flow list as admin and now it has started giving me the below error: Error: The List Flows as Admin API is no longer supported. Please use the List Flows as Admin (V2) API.
Steps to reproduce
By running the below powershell script: $todayRuns = m365 flow run list --environmentName $environment --flowName $flow.name --status Failed --triggerStartTime $previousDayDate --triggerEndTime $currentDayDate --asAdmin --output json | ConvertFrom-Json
Expected results
I think the V2 of the List Flows as Admin connector should be used in the code.
Actual results
Giving error on execution the powershell script.
Diagnostics
No response
CLI for Microsoft 365 version
v7.0.0
nodejs version
v20.10.0
Operating system (environment)
Windows
Shell
Windows PowerShell
cli doctor
No response
Additional Info
No response
Thank you for logging this issue. Seems like the command is still working on my tenant. In which region is your tenant located?
Could you run m365 cli doctor and paste the output here?
Additionally, you can append --debug to your command to see what's going on exactly. Could be useful if we can see that as well.
My tenant is in Spain region. the output of m365 cli doctor is as below:
{
"os": {
"platform": "win32",
"version": "Windows 11 Pro",
"release": "10.0.22000"
},
"cliVersion": "7.9.0",
"nodeVersion": "v20.10.0",
"cliAadAppId": "31359c7f-bd7e-475c-86db-fdb8c937548e",
"cliAadAppTenant": "common",
"authMode": "DeviceCode",
"cliEnvironment": "",
"cliConfig": {},
"roles": [],
"scopes": {
"https://graph.microsoft.com": [
"AllSites.FullControl",
"AppCatalog.ReadWrite.All",
"AuditLog.Read.All",
"Bookings.Read.All",
"ChannelMember.ReadWrite.All",
"ChannelMessage.Read.All",
"ChannelMessage.Send",
"ChannelSettings.ReadWrite.All",
"Chat.Read",
"Chat.ReadWrite",
"Directory.AccessAsUser.All",
"Directory.ReadWrite.All",
"ExternalConnection.ReadWrite.All",
"Group.ReadWrite.All",
"IdentityProvider.ReadWrite.All",
"Mail.ReadWrite",
"Mail.Send",
"Notes.Read.All",
"Place.Read.All",
"Policy.Read.All",
"Reports.Read.All",
"SecurityEvents.Read.All",
"ServiceHealth.Read.All",
"ServiceMessage.Read.All",
"ServiceMessageViewpoint.Write",
"Tasks.ReadWrite",
"Team.Create",
"TeamMember.ReadWrite.All",
"TeamsAppInstallation.ReadWriteForUser",
"TeamSettings.ReadWrite.All",
"TeamsTab.ReadWrite.All",
"TermStore.ReadWrite.All",
"User.Invite.All",
"User.ReadWrite.All",
"profile",
"openid",
"email"
],
"https://management.azure.com/": [
"user_impersonation"
],
"https://unitednations.sharepoint.com": [
"AllSites.FullControl",
"AppCatalog.ReadWrite.All",
"AuditLog.Read.All",
"Bookings.Read.All",
"ChannelMember.ReadWrite.All",
"ChannelMessage.Read.All",
"ChannelMessage.Send",
"ChannelSettings.ReadWrite.All",
"Chat.Read",
"Chat.ReadWrite",
"Directory.AccessAsUser.All",
"Directory.ReadWrite.All",
"ExternalConnection.ReadWrite.All",
"Group.ReadWrite.All",
"IdentityProvider.ReadWrite.All",
"Mail.ReadWrite",
"Mail.Send",
"Notes.Read.All",
"Place.Read.All",
"Policy.Read.All",
"Reports.Read.All",
"SecurityEvents.Read.All",
"ServiceHealth.Read.All",
"ServiceMessage.Read.All",
"ServiceMessageViewpoint.Write",
"Tasks.ReadWrite",
"Team.Create",
"TeamMember.ReadWrite.All",
"TeamsAppInstallation.ReadWriteForUser",
"TeamSettings.ReadWrite.All",
"TeamsTab.ReadWrite.All",
"TermStore.ReadWrite.All",
"User.Invite.All",
"User.ReadWrite.All"
]
}
}
@milanholemans Any update on the issue please?
Hi @IkramullahQuraishi, sorry for the late reply. Being quite busy the last couple of days. It's annoying that I cannot seem to reproduce your issue. Additionally, can't find much info about this error listing Power Automate flow runs. Is the command m365 flow list failing for you with the same error?
@IkramullahQuraishi is the flow run overview in the Power Automate UI still working for you? When you visit the page with all your PA flows, could you see in your network inspector which API request is made? The request should contain the word /runs.
Hi @IkramullahQuraishi, sorry for the late reply. Being quite busy the last couple of days. It's annoying that I cannot seem to reproduce your issue. Additionally, can't find much info about this error listing Power Automate flow runs. Is the command
m365 flow listfailing for you with the same error?
Thanks for the response. I'm eagerly waiting for a fix. Recently, the List Flow as Admin connector has started throwing errors, even in Power Automate (PA) flows, and is prompting me to use version 2 (V2) of the connector. However, Microsoft has deprecated this connector, and I believe that m365 is still referencing the outdated connector, which is causing the error.
@milanholemans Please see my complete script below:
m365 login
$environment = 'f98ac0a3-5cd6-48b6-bde4-045ec949120c'
$csvFile = 'C:\\Users\\FlowRunsFiles\\FlowData.csv' # change this to the path and name of your csv file
$flows = m365 flow list --environmentName $environment --query '[].{name: name, displayName: properties.displayName,owner: properties.creator.userId, state: properties.state, created: properties.createdTime, lastModified: properties.lastModifiedTime, trigger: properties.definitionSummary.triggers[0].swaggerOperationId, triggerType: properties.definitionSummary.triggers[0].type }' --asAdmin --output json
$flows = $flows | ConvertFrom-Json
$currentDayDate = (Get-Date).ToUniversalTime().ToString("o")
$previousDayDate = (Get-Date).AddDays(-1).ToUniversalTime().ToString("o")
$uniqueOwners = $flows.owner | Sort-Object | Get-Unique
$userMap = @{}
$uniqueOwners | ForEach-Object {
m365 aad user get --id $_ --output json | ConvertFrom-Json
} | ForEach-Object {
$userMap.Add($_.id, @{
upn = $_.userPrincipalName
displayName = $_.displayName
mail = $_.mail
}
)
}
$flows | ForEach-Object {
$_ | Add-Member -MemberType NoteProperty -Name "upn" -Value $userMap[$_.owner].upn
$_ | Add-Member -MemberType NoteProperty -Name "ownerName" -Value $userMap[$_.owner].displayName
$_ | Add-Member -MemberType NoteProperty -Name "ownerMail" -Value $userMap[$_.owner].mail
}
$flowData = @() # create an empty array to store the custom objects
foreach ($flow in $flows)
{
#$todayRuns = m365 flow run list --environmentName $environment --flowName $flow.name --triggerStartTime $previousDayDate --triggerEndTime $currentDayDate --output json | ConvertFrom-Json
$todayRuns = m365 flow run list --environmentName $environment --flowName $flow.name --status Failed --triggerStartTime $previousDayDate --triggerEndTime $currentDayDate --asAdmin --output json | ConvertFrom-Json
$displayName = $flow.displayName
$id = $flow.name
$CreatedBy= $flow.ownerName
$createdByEmail= $flow.ownerMail
$todayRunsCount = 0
$todaySuccessRunsCount = 0
$todayFailedRunsCount = 0
if($todayRuns.Count -gt 0)
{
$todayRunsCount = $todayRuns.Count
}
# create a custom object with the properties you want to export
$flowObject = [pscustomobject]@{
DisplayName = $displayName
Id = $id
CreatedBy= $CreatedBy
CreatedByEmail = $createdByEmail
#Runs = $todayRunsCount
#Succeeded = $todaySuccessRunsCount
FailedRuns = $todayRunsCount
}
# add the custom object to the array
$flowData += $flowObject
}
# export the array to the csv file
$flowData | Export-Csv -Path $csvFile -NoTypeInformation
Write-host 'upload files and folders from directory example'
function Import-FilesAndFolders(
[Parameter(Mandatory = $True)][string] $folderPath,
[Parameter(Mandatory = $True)][string] $sPFolderPath,
[Parameter(Mandatory = $True)][string] $siteUrl) {
$items = Get-ChildItem -Path $folderPath
foreach ($item in $items) {
if ((Get-Item $item.FullName) -is [System.IO.DirectoryInfo]) {
Write-host "creating folder $item"
$folderCreated = m365 spo folder add --webUrl $siteUrl --parentFolderUrl $sPFolderPath --name $item.Name
Write-host "importing folder $item"
Import-FilesAndFolders -folderPath $item.FullName -sPFolderPath "$sPFolderPath/$($item.Name)" -siteUrl $siteUrl
}
else {
Write-host "importing file $item"
m365 spo file add --webUrl $siteUrl --folder $sPFolderPath --path $item.FullName
}
}
}
$importFolderPath = 'C:\\Users\\FlowRunsFiles'
$sPFolderPath = '/Shared Documents/FlowRuns'
$siteUrl = 'https://contoso.sharepoint.com/sites/PowerPlatform'
Import-FilesAndFolders -folderPath $importFolderPath -sPFolderPath $sPFolderPath -siteUrl $siteUrl
Hi @IkramullahQuraishi, sorry for the late reply. Being quite busy the last couple of days. It's annoying that I cannot seem to reproduce your issue. Additionally, can't find much info about this error listing Power Automate flow runs. Is the command
m365 flow listfailing for you with the same error?
It is List Flow as admin which is causing the issue
@IkramullahQuraishi thank you for additional info 👍. You Rock 🤩 We are investigating the issue 👍
Thank you @IkramullahQuraishi for the extra info. It makes sense that flow list command fails. In your issue, you were referencing flow run list, that's why I was a bit confused 😊.
Since the v2 returns data in a slightly difference format, do we consider this a bug or a breaking change? The annoying thing is that the command still works for some tenants (including mine).
@pnp/cli-for-microsoft-365-maintainers
Ok, we decided it's a bug. Let's get this fixed!
we decided to go with a new major release (v8) ASAP which the primary change will be fixup to this issue 👍. All other related work that were targeted for next major will be part of v9 in order not to delay this fix
Apologies for jumping ahead here, I spied the new Beta release and installed in my environment, but still getting the same error sadly.
# Set the output file name
PS C:\PowerAutomateReporting> $flows = m365 flow list -e {redacted} --asAdmin | ConvertFrom-Json
PS C:\PowerAutomateReporting> $flows
error
-----
The List Flows as Admin API is no longer supported. Please use the List Flows as Admin (V2) API.
PS C:\PowerAutomateReporting> m365 version
"v8.0.0-beta.d20a60e"
PS C:\PowerAutomateReporting> m365 version
"v8.0.0-beta.d20a60e"
PS C:\PowerAutomateReporting> m365 flow list -e {redacted} --asAdmin | ConvertFrom-Json
error
-----
The List Flows as Admin API is no longer supported. Please use the List Flows as Admin (V2) API.
PS C:\PowerAutomateReporting> m365 cli doctor
{
"os": {
"platform": "win32",
"version": "Windows 10 Pro",
"release": "10.0.19044"
},
"cliVersion": "8.0.0-beta.d20a60e",
"nodeVersion": "v20.15.1",
"cliAadAppId": "{redacted}",
"cliAadAppTenant": "single",
"authMode": "Password",
"cliEnvironment": "",
"cliConfig": {
"showSpinner": false,
"errorOutput": "stdout",
"printErrorsAsPlainText": false
},
"roles": [],
"scopes": {
"https://graph.microsoft.com": [
"AllSites.Read",
"User.Read.All",
"profile",
"openid",
"email"
],
"https://management.azure.com/": [
"user_impersonation"
]
}
}
PS C:\PowerAutomateReporting> m365 flow list -e {redacted} --asAdmin | ConvertFrom-Json --debug
ConvertFrom-Json: The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
PS C:\PowerAutomateReporting> m365 flow list -e {redacted} --asAdmin ---debug
{"error":"The List Flows as Admin API is no longer supported. Please use the List Flows as Admin (V2) API."}
PS C:\PowerAutomateReporting> m365 flow list -e {redacted} --asAdmin --debug
Executing command flow list with options {"options":{"environmentName":"{redacted}","asAdmin":true,"debug":true,"output":"json"}}
Executing command as '{redacted}', appId: {redacted}, tenantId: {redacted}
Existing access token {token_redacted} Returning...
Request:
{
"url": "https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple/scopes/admin/environments/{redacted}/flows?api-version=2016-11-01",
"method": "get",
"headers": {
"Accept": "application/json;odata.metadata=none",
"user-agent": "NONISV|SharePointPnP|CLIMicrosoft365/8.0.0-beta.d20a60e",
"accept-encoding": "gzip, deflate",
"X-ClientService-ClientTag": "M365CLI:8.0.0-beta.d20a60e",
"odata-version": "4.0",
"authorization": "{redacted}"
},
"responseType": "json",
"decompress": true
}
Request error:
{
"url": "https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple/scopes/admin/environments/{redacted}/flows?api-version=2016-11-01",
"status": 403,
"statusText": "Forbidden",
"headers": {
"content-length": "166",
"content-type": "application/json; charset=utf-8",
"date": "Thu, 11 Jul 2024 08:36:14 GMT",
"cache-control": "no-store, no-cache",
"strict-transport-security": "max-age=31536000; includeSubDomains",
"x-ms-islandgateway": "GA00000IO, GA000005D",
"x-ms-request-id": "uksouth:f0528546-bb29-4cf1-ad25-bc93ff40e939",
"x-ms-correlation-request-id": "59d5f31b-f9a4-4015-bf4f-f8c00a4c53dc",
"x-ms-flow-mobile-ios-version": "3.0.421",
"x-ms-flow-routing-request-id": "WESTEUROPE:20240711T083615Z:59d5f31b-f9a4-4015-bf4f-f8c00a4c53dc",
"server-timing": "x-ms-igw-upstream-headers;dur=25.4,x-ms-igw-req-overhead;dur=0.8",
"x-content-type-options": "nosniff",
"x-ms-service-request-id": "3777999a-e806-4a0d-bc62-b4f2ce9367b5",
"x-ms-correlation-id": "702d6fe8-e4ff-4c10-b39d-68b65ecbef44",
"x-ms-activity-vector": "00.01.IN.0F.00"
},
"error": {
"error": {
"code": "CannotListFlowsAsAdminWithDefinition",
"message": "The List Flows as Admin API is no longer supported. Please use the List Flows as Admin (V2) API."
}
}
}
Timings:
api: 267.812ms
core: 17.6656ms
command: 306.7324ms
options: 0.325504ms
total: 327.0104ms
validation: 0.736704ms
{"error":"The List Flows as Admin API is no longer supported. Please use the List Flows as Admin (V2) API."}
Hi @StevieBleeds, this fix isn't available yet in the latest beta release. PR is open, but not merged yet: #6135 We'll do our best to get this in the next beta ASAP. This will likely be in the coming days.
Brilliant, thanks @milanholemans
As a temporary solution, you can use the command below to get all your flows as admin:
m365 request --method get --url "https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple/scopes/admin/environments/{Your environment name}/v2/flows?api-version=2016-11-01"
We're working on implementing it in the new beta release, so should be available in a couple of days @StevieBleeds.
Thanks for your efforts guys!
@IkramullahQuraishi, @StevieBleeds. The fix from @milanholemans is live in the latest beta release. Check it out and see if it helps! To use the beta version of the CLI, add @next to the package name when installing: npm install -g @pnp/cli-microsoft365@next.