Hi Eprach,
Thanks for the info. Does the issue occur if the file upload query "/drives/<DriveID>/root:/Document.docx:/content?@microsoft.graph.conflictBehavior=replace" is run by itself?
Thanks.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi Team,
I work on an app using the SDK and I would like to upload files from file system to SharePoint Online.
Below is part of my code:
BatchRequestContentCollection batch = new BatchRequestContentCollection(MSGraphService.graphClient, fileShareitems.Count());
using (FileStream fs = File.OpenRead(item.Path))
{
var fileUploadRequest = graphClient.Drives[drive.Id]
.Root
.ItemWithPath(uploadInfo[1]).Content.ToPutRequestInformation(fs);
fileUploadRequest.URI = new Uri(fileUploadRequest.URI.OriginalString + "?@microsoft.graph.conflictBehavior=rename");
var result = await batch.AddBatchRequestStepAsync(fileUploadRequest);
var returnedResponse = await MSGraphService.graphClient.Batch.PostAsync(batch);
var fileResponse = await returnedResponse.GetResponseByIdAsync<DriveItem>(result);
}
I expect to have my files saved to the right document library but I get the following issue:
'e' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker) at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first) at System.Text.Json.Utf8JsonReader.ReadSingleSegment() at System.Text.Json.Utf8JsonReader.Read() at System.Text.Json.JsonDocument.Parse(ReadOnlySpan1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack)
at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedArrayPoolBytes, PooledByteBufferWriter extraPooledByteBufferWriter) at System.Text.Json.JsonDocument.Parse(Stream utf8Json, JsonDocumentOptions options) at Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory.GetRootParseNode(String contentType, Stream content) at Microsoft.Kiota.Abstractions.Serialization.ParseNodeProxyFactory.GetRootParseNode(String contentType, Stream content) at Microsoft.Kiota.Abstractions.Serialization.ParseNodeFactoryRegistry.GetRootParseNode(String contentType, Stream content) at Microsoft.Graph.ResponseHandler1.d__3.MoveNext()
at Microsoft.Graph.ResponseHandler1.<HandleResponseAsync>d__22.MoveNext()
at Microsoft.Graph.BatchResponseContent.d__7`1.MoveNext()
If I try to upload my files without batching by using these samples:
It works well.
Could you please help me pointing what I am doing wrong?
My config:
Request also posted here: https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/2089
Hi Eprach,
Thanks for the info. Does the issue occur if the file upload query "/drives/<DriveID>/root:/Document.docx:/content?@microsoft.graph.conflictBehavior=replace" is run by itself?
Thanks.