Skip to content

Get-MgReportSharePointSiteUsageDetail204B is failing #894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
maisarissi opened this issue Oct 6, 2021 · 3 comments
Closed

Get-MgReportSharePointSiteUsageDetail204B is failing #894

maisarissi opened this issue Oct 6, 2021 · 3 comments
Assignees

Comments

@maisarissi
Copy link

maisarissi commented Oct 6, 2021

Per the documentation I should be able to use the cmdlet as follows:

Get-MgReportSharePointSiteUsageDetail204B -Period "D90" -OutFile "C:\Development\PowerShell\MyFile.csv"

Besides the weird cmdlet name, I'm getting an error:

DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: CmdletProcessRecordAsyncStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: https://graph.microsoft.com/v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(period='D90')
DEBUG: RequestCreated: https://graph.microsoft.com/v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(period='D90')
DEBUG: HeaderParametersAdded: https://graph.microsoft.com/v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(period='D90')
DEBUG: GET /v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(period='D90') HTTP/1.1
HTTP: graph.microsoft.com
DEBUG: BeforeCall:
DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletException: InvalidOperationException - The stream was already consumed. It cannot be read again. : at System.Net.Http.HttpConnectionResponseContent.ConsumeStream()
at System.Net.Http.HttpConnectionResponseContent.CreateContentReadStreamAsync()
at System.Net.Http.HttpContent.CreateContentReadStreamAsync(CancellationToken cancellationToken)
at System.Net.Http.HttpContent.ReadAsStreamAsync(CancellationToken cancellationToken)
at System.Net.Http.HttpContent.ReadAsStreamAsync()
at Microsoft.Graph.PowerShell.HttpMessageFormatter.b__28_0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
at Microsoft.Graph.PowerShell.HttpMessageFormatter.TryComputeLength(Int64& length)
at System.Net.Http.HttpContent.GetComputedOrBufferLength()
at System.Net.Http.Headers.HttpContentHeaders.get_ContentLength()
at System.Net.Http.HttpContent.CreateMemoryStream(Int64 maxBufferSize, Exception& error)
at System.Net.Http.HttpContent.CreateTemporaryBuffer(Int64 maxBufferSize, MemoryStream& tempBuffer, Exception& error)
at System.Net.Http.HttpContent.LoadIntoBufferAsync(Int64 maxBufferSize, CancellationToken cancellationToken)
at System.Net.Http.HttpContent.ReadAsStringAsync(CancellationToken cancellationToken)
at System.Net.Http.HttpContent.ReadAsStringAsync()
at Microsoft.Graph.PowerShell.Module.Finally(String id, CancellationToken cancellationToken, Func`1 getEventData, Func`4 signal)
at Microsoft.Graph.PowerShell.Module.EventHandler(String id, CancellationToken cancellationToken, Func`1 getEventData, Func`4 signal, InvocationInfo invocationInfo, String parameterSetName, Exception exception)
at Microsoft.Graph.PowerShell.Module.Signal(String id, CancellationToken token, Func`1 getEventData, Func`4 signal, InvocationInfo invocationInfo, String parameterSetName, Exception exception)
at Microsoft.Graph.PowerShell.Cmdlets.GetMgReportSharePointSiteUsageDetail204B_Get.Microsoft.Graph.PowerShell.Runtime.IEventListener.Signal(String id, CancellationToken token, Func`1 messageData)
at Microsoft.Graph.PowerShell.Reports.ReportsGetSharePointSiteUsageDetail204B_Call(HttpRequestMessage request, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Graph.PowerShell.Reports.ReportsGetSharePointSiteUsageDetail204B(String period, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Graph.PowerShell.Cmdlets.GetMgReportSharePointSiteUsageDetail204B_Get.ProcessRecordAsync()
at Microsoft.Graph.PowerShell.Cmdlets.GetMgReportSharePointSiteUsageDetail204B_Get.ProcessRecordAsync()
Get-MgReportSharePointSiteUsageDetail204B_Get: The stream was already consumed. It cannot be read again.
DEBUG: CmdletProcessRecordEnd:
DEBUG: CmdletEndProcessing:

As a workaround, I can successfully call Invoke-MgGraphRequest:

$url = "https://graph.microsoft.com/v1.0/reports/getSharePointSiteUsageDetail(period='D90')"
Invoke-MgGraphRequest -Method Get -Uri $url -OutputFilePath "C:\Development\PowerShell\MyFile.csv"

There is also another cmdlet to get sites usage, but per date (not sure why there are 2 different cmdlets instead of the same cmdlet but using different parameters):

Get-MgReportSharePointSiteUsageDetailD27A -Date 2021-10-05 -OutFile "C:\Development\PowerShell\MyFile.csv"

And I'm getting this error:

DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: CmdletProcessRecordAsyncStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: https://graph.microsoft.com/v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(date==2021-10-05)
DEBUG: RequestCreated: https://graph.microsoft.com/v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(date==2021-10-05)
DEBUG: HeaderParametersAdded: https://graph.microsoft.com/v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(date==2021-10-05)
DEBUG: GET /v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(date==2021-10-05) HTTP/1.1
HTTP: graph.microsoft.com
DEBUG: BeforeCall:
DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
Get-MgReportSharePointSiteUsageDetailD27A_Get: Expression expected at position 5 in 'date==2021-10-05'.
DEBUG: GET https://graph.microsoft.com/v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(date==2021-10-05)
HTTP/1.1 400 Bad Request
Date: Wed, 06 Oct 2021 19:00:03 GMT
Transfer-Encoding: chunked
Vary: Accept-Encoding
Strict-Transport-Security: max-age=31536000
request-id: c70c031d-4298-4b30-8987-a5046ecf0bf6
client-request-id: c70c031d-4298-4b30-8987-a5046ecf0bf6
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"Brazil South","Slice":"E","Ring":"3","ScaleUnit":"002","RoleInstance":"CP1PEPF0000287F"}}
Content-Type: application/json
Content-Encoding: gzip
{"error":{"code":"BadRequest","message":"Expression expected at position 5 in 'date==2021-10-05'.","innerError":{"date":"2021-10-06T19:00:03","request-id":"c70c031d-4298-4b30-8987-a5046ecf0bf6","client-request-id":"c70c031d-4298-4b30-8987-a5046ecf0bf6"}}}
DEBUG: Finally:
DEBUG: CmdletAfterAPICall:
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: CmdletEndProcessing:

And it's also possible to do the workaround for this scenario using Invoke-MgGraphRequest:

$url = "https://graph.microsoft.com/v1.0/reports/getSharePointSiteUsageDetail(date=2021-10-05)"
Invoke-MgGraphRequest -Method Get -Uri $url -OutputFilePath "C:\Development\PowerShell\MyFile.csv"
@ghost ghost added the ToTriage label Oct 6, 2021
@maisarissi maisarissi changed the title Get-MgReportSharePointSiteUsageDetail204B is failing due to parser error Get-MgReportSharePointSiteUsageDetail204B is failing Oct 6, 2021
@maisarissi
Copy link
Author

Related to #407

@peombwa
Copy link
Member

peombwa commented Oct 6, 2021

The weird command name is from the operationId in the OpenAPI document that the SDK is generated from. Will be fixed by microsoftgraph/microsoft-graph-devx-api#728.

The first error is related to #407. The metadata needs to be updated to reflect how the API works https://docs.microsoft.com/en-us/graph/api/reportroot-getsharepointsiteusagedetail?view=graph-rest-1.0.

The double == when -Date 2021-10-05 parameter is specified appears to be a formatting bug with cmdlet. We will use this issue to track this bug. All other issues will be fixed in the aforementioned issues.

@peombwa
Copy link
Member

peombwa commented Jun 20, 2022

Closing as duplicated of #407. A fix will be provided by #1331.

@peombwa peombwa closed this as completed Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants