Set-MgDriveItemContent uses incorrectly formatted graph end ppoint

Abierto
#3,772 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
powershell
Área
api

Línea de trabajo

Comience en el punto de entrada Set-MgDriveItemContent y reproduzca el problema con los uploadParams proporcionados y la salida de Debug. Rastree cómo se coloca DriveItemId en la URL de Graph y, a continuación, verifique que el endpoint resultante conserve los delimitadores :/content documentados y que la carga de texto se complete correctamente sin el error de JSON Content-Type.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

status:waiting-for-triage type:bug
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:

https://graph.microsoft.com/v1.0/drives/b!kA4oXXXXXPLsSjEJ7S4dfN9wGhCpAhUgEYHvSBfKhADBMk4wiQ519UTHUsHC6/items/root:/results-12.txt:/content

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

Absolute Uri:
https://graph.microsoft.com/v1.0/drives/b%21kA4oNtZbvEKpPLsSjEJ7S4dfN9wGhCpAhUgEYHvSBfKhADBMk4wiQ519UTHUsHC6/items/root%3A%2Fresults-55.txt/content

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_
Lenguaje dominante
C#
Estrellas
898
Forks
230
Merge medio
2 d 5 h
PR fusionados (30 d)
31

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoftgraph/msgraph-sdk-powershell

Todos los issues de microsoftgraph/msgraph-sdk-powershell

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.