File tree Expand file tree Collapse file tree 4 files changed +16
-1
lines changed
src/Authentication/Authentication Expand file tree Collapse file tree 4 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -453,6 +453,10 @@ internal async Task ProcessResponseAsync(HttpResponseMessage response)
453453 throw new ArgumentOutOfRangeException ( nameof ( OutputType ) ) ;
454454 }
455455 break ;
456+ case RestReturnType . PlainText :
457+ responseString = await response . Content . ReadAsStringAsync ( ) ;
458+ WriteObject ( responseString ) ;
459+ break ;
456460 case RestReturnType . OctetStream :
457461 if ( OutputType == OutputType . HttpResponseMessage )
458462 WriteObject ( response ) ;
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ internal static RestReturnType CheckReturnType(this HttpResponseMessage response
2929 rt = RestReturnType . Image ;
3030 else if ( IsOctetStream ( contentType ) )
3131 rt = RestReturnType . OctetStream ;
32+ else if ( IsPlainText ( contentType ) )
33+ rt = RestReturnType . PlainText ;
3234 return rt ;
3335 }
3436
@@ -80,6 +82,8 @@ private static bool CheckIsOctetStream(string contentType)
8082 return isOctetStream ;
8183 }
8284
85+ private static bool IsPlainText ( string contentType ) => contentType . Equals ( "text/plain" , StringComparison . OrdinalIgnoreCase ) ;
86+
8387 // used to split contentType arguments
8488 private static readonly char [ ] ContentTypeParamSeparator = { ';' } ;
8589
Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ public enum RestReturnType
2424 /// <summary>
2525 /// image/* (image/jpeg, image/png) return type
2626 /// </summary>
27- Image = 4
27+ Image = 4 ,
28+ /// <summary>
29+ /// text/plain return type
30+ /// </summary>
31+ PlainText = 5
2832 }
2933}
Original file line number Diff line number Diff line change @@ -54,6 +54,9 @@ Describe 'Invoke-MgGraphRequest Command' -skip {
5454 It ' Should not throw when -InferOutputFilePath is specified' {
5555 { Invoke-MgGraphRequest - OutputType PSObject - Uri " https://graph.microsoft.com/v1.0/reports/getTeamsUserActivityUserDetail(period='D7')" - InferOutputFileName } | Should -Not - Throw
5656 }
57+ It ' Should return plain text' {
58+ { Invoke-MgGraphRequest - Uri " https://graph.microsoft.com/v1.0/applications/`$ count" } | Should - BeOfType [System.String ]
59+ }
5760 }
5861
5962 Context ' Absolute and relative URIs' {
You can’t perform that action at this time.
0 commit comments