Set-MgDriveItemContent uses incorrectly formatted graph end ppoint
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- powershell
- Ambito
- api
Direzione di ricerca
Parti dal punto di ingresso Set-MgDriveItemContent e riproduci il problema con gli uploadParams forniti e l’output di Debug. Traccia il modo in cui DriveItemId viene inserito nell’URL Graph, quindi verifica che l’endpoint risultante mantenga i delimitatori :/content documentati e che il caricamento del testo abbia esito positivo senza l’errore JSON Content-Type.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
I am using Set-MgDriveItemContent to upload a small test text document. It fails with the error:
Entity only allows writes with a JSON Content-Type header.
When running the command with the -Debug flag, I can see the absolute url that is using:
DEBUG: Content type text/plain
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
PUT
Absolute Uri:
https://graph.microsoft.com/v1.0/drives/b%21kA4oNtZbvEKpPLsSjEJ7S4dfN9wGhCpAhUgEYHvSBfKhADBMk4wiQ519UTHUsHC6/items/root%3A%2Fresults-12.txt/content
The url ends with /content but per the documentation, it should end with :/content
Expected behavior
Using Invoke-MgGraphRequest and a properly edited url, the upload works:
Name Value
size 80
webUrl https://contoso.sharepoint.com/sites/o365/LicenseProcessResults/results-12.txt
cTag "c:{8567605F-7A07-491F-8473-C8D249B50820},1"
file {[mimeType, text/plain], [hashes, System.Collections.Hashtable]}
@odata.context https://graph.microsoft.com/v1.0/$metadata#drives('b%21kA4oNtZbXXXXLsSjEJ7S4dfN9wGhCpAhUgEYHv…
parentReference {[siteId, 36280e90-5bd6-42bc-a93c-bb128c427b4b], [driveType, documentLibrary], [driveId, b!kA4…
lastModifiedBy {[application, System.Collections.Hashtable], [user, System.Collections.Hashtable]}
id 016IHMIYS7MBTYKB32D5EYI46I2JE3KCBA
isAuthoritative False
eTag "{8567605F-7A07-491F-8473-C8D249B50820},1"
createdBy {[application, System.Collections.Hashtable], [user, System.Collections.Hashtable]}
name results-12.txt
shared {[scope, users]}
fileSystemInfo {[createdDateTime, 9/15/2026 2:24:13 PM], [lastModifiedDateTime, 9/15/2026 2:24:13 PM]}
@microsoft.graph.downloadUrl https://contoso.sharepoint.com/sites/o365/_layouts/15/download.aspx?UniqueId=8567605f-7a07-491f-…
lastModifiedDateTime 9/15/2026 2:24:13 PM
createdDateTime 9/15/2026 2:24:13 PM
How to reproduce
$drive = ... #set to the value of a drive in a SharePoint or Onedrive site
$uploadParams = @{
'DriveId' = $drive.Id
'DriveItemId' = 'root:/some-file-name.txt
'InFile' = "$PSScriptRoot\sample.txt" #just create a small file with some sample text
'ContentType' = 'text/plain'
'Debug' = $true
}
Set-MgDriveItemContent @uploadParams
SDK Version
2.39.0
Latest version known to work for scenario above?
No response
Known Workarounds
Use Invoke-MgGraphRequest to manually construct the url of the graph to communicate with
Debug output
Click to expand log
```DEBUG: [CmdletBeginProcessing]: - Set-MgDriveItemContent begin processing with parameterSet 'Set'.
DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'InteractiveBrowser', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph Command Line Tools'.
DEBUG: [Authentication]: - Scopes: [AccessReview.Read.All, AccessReview.ReadWrite.All, AccessReview.ReadWrite.Membership, Application.Read.All, Application.ReadWrite.All, AppRoleAssignment.ReadWrite.All, AuditLog.Read.All, AuditLogsQuery.Read.All, Bookings.Read.All, ChannelMessage.ReadWrite, ChannelSettings.Read.All, DelegatedPermissionGrant.Read.All, DelegatedPermissionGrant.ReadWrite.All, Device.Read.All, DeviceManagementManagedDevices.Read.All, Directory.Read.All, Directory.ReadWrite.All, email, ExternalItem.Read.All, Files.Read, Group.Read.All, Group.ReadWrite.All, GroupMember.Read.All, IdentityRiskEvent.Read.All, OnPremDirectorySynchronization.Read.All, openid, Organization.Read.All, Policy.Read.All, Policy.ReadWrite.ApplicationConfiguration, PrivilegedAccess.Read.AzureAD, PrivilegedAccess.Read.AzureADGroup, PrivilegedAssignmentSchedule.Read.AzureADGroup, PrivilegedEligibilitySchedule.Read.AzureADGroup, profile, RoleManagement.Read.Directory, RoleManagement.ReadWrite.Directory, Sites.FullControl.All, Team.ReadBasic.All, TeamMember.Read.All, TeamworkDevice.Read.All, TeamworkTag.ReadWrite, User.Read, User.Read.All, User.ReadBasic.All, User.ReadWrite.All, UserAuthenticationMethod.Read.All].
DEBUG: Content type text/plain
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
PUT
Headers:
FeatureFlag : 00000003
Cache-Control : no-store, no-cache
User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.26100; en-US),PowerShell/7.6.5
SdkVersion : graph-powershell/2.39.0
client-request-id : 30e376a5-b08b-4c52-93df-524861239763
Accept-Encoding : gzip,deflate
Body:
This is a test upload file created at 09/14/2026 18:04:57
105
Mark was here.
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
BadRequest
Headers:
Transfer-Encoding : chunked
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : fa1da99e-e33b-43f5-bdb7-ca5b83de0399
client-request-id : 30e376a5-b08b-4c52-93df-524861239763
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"Central US","Slice":"E","Ring":"4","ScaleUnit":"004","RoleInstance":"DS2PEPF00003844"}}
Date : Tue, 15 Sep 2026 14:29:54 GMT
Body:
{
"error": {
"code": "BadRequest",
"message": "Entity only allows writes with a JSON Content-Type header.",
"innerError": {
"date": "2026-09-15T14:29:55",
"request-id": "fa1da99e-e33b-43f5-bdb7-ca5b83de0399",
"client-request-id": "30e376a5-b08b-4c52-93df-524861239763"
}
}
}
</details>
### Configuration
Windows 11 x64
$PSVersionTable
Name Value
PSVersion 7.6.5
PSEdition Core
GitCommitId 7.6.5
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.4
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
### Other information
_No response_
- Lingua principale
- C#
- Stelle
- 901
- Fork
- 232
- Merge medio
- 1g 9h
- PR unite (30g)
- 24
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoftgraph/msgraph-sdk-powershell
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
microsoftgraph/msgraph-sdk-powershell#3752 ·
I maintainer di solito rispondono entro 1 giorno
-
status:waiting-for-triage type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
microsoftgraph/msgraph-sdk-powershell#3751 ·
I maintainer di solito rispondono entro 1 giorno
-
Needs: Attention :wave: status:waiting-for-triage type:bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
microsoftgraph/msgraph-sdk-powershell#3810 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
status:waiting-for-triage type:feature
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
microsoftgraph/msgraph-sdk-powershell#3806 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Microsoft.Graph.Authentication fails after removal and re-import in the same PowerShell sessionApertastatus:waiting-for-triage type:bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
microsoftgraph/msgraph-sdk-powershell#3805 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di microsoftgraph/msgraph-sdk-powershell
Issue simili
-
[Bug]: Missing extensions in Agent Card capabilities in v0.3 compat modeForse già presa @hwanders l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
a2aproject/a2a-dotnet#514 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
agentic-workflows untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
VS Code
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
AlamoEngine-Tools/pg-starwarsgame-lsp#207 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
elsa-workflows/elsa-core#8593 ·
I maintainer di solito rispondono entro 1 giorno
-
GpioController.QueryComponentInformation() throws NotSupportedException with RaspberryPi3DriverApertauntriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100