I'm using Onedrive's "upload item from URL" functionality. https://dev.onedrive.com/items/upload_url.htm
Much of the time it works okay -- over the past years I've uploaded several thousand files this way. But over the past few days I've been trying to batch-upload about 4000 items and this "upload from URL" hasn't worked right...
What I see on about 9/10 of my uploads is it accepts the upload-from-URL request, and gives me back a "progress URL" to monitor, but that progress URL stays consistently at "status=notStarted" and "percentageComplete=0%" until I give up after five minutes.
Has anyone used the upload-from-URL functionality? Any experience with it being flakey?
I don't think it's down to rate-limiting. That's because I stopped my code for the day, restarted it the next day, and got the same behavior.
I wonder if it has something to do with this particular target filename to upload to being wrong? maybe OneDrive has got in a weird state where it doesn't feel able to upload to this particular filename via sideload?
(I guess my next attempt will be to do a regular upload and see what kind of error message that gives...)
' Initiate a sideload from the blobURL into OneDrive
Dim sideReqUrl = $"https://api.onedrive.com/v1.0/drive/root:{escapedFolder}:/children?access_token={accessToken}"
Dim sideReqContent = JsonConvert.SerializeObject(New JObject From {{"@content.sourceUrl", blobUrl}, {"@name.conflictBehavior", "fail"}, {"name", unescapedName}, {"file", New JObject}})
Dim sideReq As New HttpRequestMessage(HttpMethod.Post, sideReqUrl)
sideReq.Headers.Add("Prefer", "respond-async")
sideReq.Content = New StringContent(sideReqContent, Text.Encoding.UTF8, "application/json")
Dim sideResp = Await client.SendAsync(sideReq, cancel)
If sideResp.StatusCode <> Net.HttpStatusCode.Accepted Then
Console.WriteLine($"sideload rejected - {sideResp}")
Throw New Net.Http.HttpRequestException("sideload rejected")
End If
Dim progUrl = sideResp.Headers.Location ' for monitoring progress
Console.WriteLine($"sideload started - {progUrl}")
' Poll the progress of that sideload until it's complete
Do
Dim progResp = Await client.GetAsync(progUrl, cancel)
If progResp.StatusCode <> Net.HttpStatusCode.Accepted Then progResp.EnsureSuccessStatusCode()
Dim progRespText = Await progResp.Content.ReadAsStringAsync()
Dim progRespJson = JObject.Parse(progRespText)
If progResp.StatusCode = Net.HttpStatusCode.Accepted Then
Console.WriteLine($"sideload ping - {CStr(progRespJson("status"))} - {CStr(progRespJson("percentageComplete"))}%")
Continue Do
End If
Console.WriteLine("SIDELOAD COMPLETE!")
Return
Loop