Upload de ficheros a una carpeta en Sharepoint

Paco Sanchez 0 Reputation points
2023-02-08T13:23:34.1033333+00:00

Buenas tardes

Estoy intentando hacer upload de ficheros en una carpeta de SharePoint utilizando HttpClient(), el token que uso es valido ya que me funciona descargando ficheros, el código es el siguiente:

Dim HClientSubida = New System.Net.Http.HttpClient()

URL = "https://graph.microsoft.com/v1.0/groups/032b56h................

HClientSubida.DefaultRequestHeaders.Authorization = New System.Net.Http.Headers.AuthenticationHeaderValue(Token)

HClientSubida.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue("application/json"))

HClientSubida.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8")

dim strNombre="C:\prueba.pdf"

dim NombreArchivo="prueba.pdf"

dim CC as stream

CC=file.OpenRead

Dim conten = New MultipartFormDataContent()

conten.Headers.ContentType.MediaType = "application/json"

conten.Add(New System.Net.Http.StreamContent(CC), "Prueba", NombreArchivo)

Dim body1 As Object

body1 = JsonConvert.SerializeObject(conten)

Dim probando As HttpContent

probando = New StringContent(JsonConvert.SerializeObject(body1), UTF8Encoding.UTF8, "application/json")

Dim response4 = New HttpResponseMessage

response4 = Await HClientSubida.PostAsync(URL, probando)

Obtengo respuesta 400 y no se por donde tirar, agradezco enormemente cualquier ayuda . Gracias

StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,582 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,568 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more