2017-11-28 3 views
1

Microsoft Graph APIを使用して既存のDriveItemの内容を使用して新しいSharePoint DriveItemを作成しようとしています。しかし、DriveItemを作成しようとすると、以下のエラーが表示されます。なぜ誰かが説明できますか?DriveItem作成時に "ReadTimeoutから値を取得中にエラーが発生しました"

編集:は手動で作成したのMemoryStreamオブジェクト

GraphServiceClient graphClient = GraphSDKHelper.GetAuthenticatedClient(); 
using (var docStream = new MemoryStream(1024)) 
{ 
    var doc = new DriveItem 
    { 
     Content = docStream, 
     Name = "00_newDoc.docx", 
     ParentReference = new ItemReference 
     { 
      Id = "<folderId" 
     } 
    }; 
    var resultItem = await graphClient.Drives["<driveId>"].Items["<folderId>"].Request().CreateAsync(driveItem); 
} 

を使用するために簡素化された、私は次のように直接ファイルのコンテンツをアップロードすることができますが、私はその後、単一でDriveItemに多くのメタデータを指定する能力を失いますコール。

var resultItem = await graphClient.Drives["<driveId>"].Items["<folderId>"].ItemWithPath("00_newDoc.docx").content.Request().PutAsync<DriveItem(docStream); 

エラー:

Error getting value from 'ReadTimeout' on 'System.IO.MemoryStream'.
at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType) at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType) at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer) at Microsoft.Graph.Serializer.SerializeObject(Object serializeableObject) at Microsoft.Graph.BaseRequest.d__36.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Graph.BaseRequest.d__32 1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Graph.DriveItemRequest.<CreateAsync>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter 1.GetResult() at Informa.eDocs.AzureFunctions.Functions.PostDocToSharePoint.d__0.MoveNext()

内部例外:

Timeouts are not supported on this stream. at System.IO.Stream.get_ReadTimeout() at GetReadTimeout(Object) at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)

答えて

0

私は、問題は、あなたが遭遇していることが何であるかを知りません。

これで、ファイルストリームをダウンロードして新しいドライブアイテムとして再度アップロードする理由がありますか?

コピー機能の使用を検討しましたか?それはこのような何かを動作するはずです(私はまだ試していません):APIは、この方法を使用するものではありません

// Copy item reference 
ItemReference iRef = new ItemReference() 
{ 
    DriveId = "b!ez3F6Nysf0yYklsI2gUdcx4e7pSsSDZClwfWe3rFh4mSiYpAIn5zRLcsEeS7g5dr", 
    Id = "01YYVWN6F6Y2GOVW7725BZO354PWSELRRZ" 
}; 

// Copy it 
await graphClient.Me.Drives["<driveId>"].Items["<ItemId>"].Copy("copiedItem.txt", iRef).Request().PostAsync(); 

を更新。私はそれが一回の呼び出しで行うことができない理由を知らない。最初にPOST(フォルダを示していますが、アイデアはファイルと同じです)のアイテムを作成してから、その後の呼び出しでコンテンツストリームPUTを作成する必要があります。

+0

私は明確にすべきでした - 私はコピー機能を認識しています。これは、グラフAPIを使用して取得およびアップロードできることを示すPOCの一部に過ぎません。私の主な関心事は、私が記述した方法で新しいDriveItemを作成できない理由です。 – NSouth

関連する問題