Hello everyone.
The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Options
Transfer file to hololens via POST httprequest (error 429)
Thomas_C
✭
Hello,
I work on a desktop application to communicate with hololens glasses via httprequest (hololens is connected via USB), especially, I want to read and write files. To do that, I use the following code (code is more readable on stackoverflow) :
// Consts public static readonly string API_FileQuery = @"http://{0}/api/filesystem/apps/file"; public async static void UploadFile(ConnectInfo connectInfo, string knownfolderid, string packagefullname, string path, string filePath) { try { // Query string query = string.Format(API_FileQuery, connectInfo.IP); query += "?knownfolderid=" + Uri.EscapeUriString(knownfolderid); query += "&packagefullname=" + Uri.EscapeUriString(packagefullname); query += "&path=" + Uri.EscapeUriString(path); // Create http request var httpRequest = new HttpClient(); httpRequest.DefaultRequestHeaders.Clear(); httpRequest.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue( "Basic", EncodeTo64(connectInfo.User + ":" + connectInfo.Password)); byte[] data = File.ReadAllBytes(filePath); ByteArrayContent byteContent = new ByteArrayContent(data); HttpResponseMessage resp = await httpRequest.PostAsync(query, byteContent); var responseMessage = await resp.Content.ReadAsStringAsync(); } catch (Exception ex) { //log some problems } } // Helpers private static string EncodeTo64(string toEncode) { byte[] toEncodeAsBytes = Encoding.ASCII.GetBytes(toEncode); string returnValue = Convert.ToBase64String(toEncodeAsBytes); return returnValue; } }
I already have a GetFile method (same REST API but with GET http request) that works fine and gives me the file I want but the UploadFile method gives me the following response : StatusCode : 429, ReasonPhrase : 'Too Many Requests' (I try to upload a json file).
I don't really understand why I have this error, I just send 1 request (or I'm missing something).
For information, REST API definition can be found there.
Thanks
1
Answers
If someone is interested, I've posted an alternative solution to upload file here.
My problem is same but from device portal
Hi Thomas,
I believed I've 'solved' the issue, I posted on your SO question but I will duplicate it here:
It's possible there are other combinations of headers and body that will work, but without the spec being completed it's very difficult to know.
It would be really awesome if this bug could get to the right person, since it has been reported by at least 8 different users. (Is there an official public place for such reports?). Other reports:
https://forums.hololens.com/discussion/8962/failed-to-upload-file-error-object-object-in-device-portal
https://forums.hololens.com/discussion/8736/trying-to-upload-1-files-returns-429-too-many-requests
https://forums.hololens.com/discussion/8067/what-causes-this-error-failed-to-upload-file-error-object-object
https://forums.hololens.com/discussion/7847/getting-error-failed-to-upload-file-error-object-object-while-uploading-file
https://forums.hololens.com/discussion/6323/failed-to-upload-file-error-object-object
https://forums.hololens.com/discussion/3172/what-causes-this-error-failed-to-upload-file-error-object-object
https://forums.hololens.com/discussion/1950/open-source-c-wrapper-for-windows-device-portal-rest-api
Hello doublerebel,
As I said, I used a different solution but thank you for your answer.