Giter Club home page Giter Club logo

Comments (6)

texroemer avatar texroemer commented on September 27, 2024

Hi,

Can you print out the status code details for status code 500? There should be error messages returned in the POST response which will get more details on what is failing.

Can you also try python script "DeviceFirmwareSimpleUpdateREDFISH.py" to see if this works? This will help narrow down if its a script issue or iDRAC issue.

Thanks

from idrac-redfish-scripting.

nildoadao avatar nildoadao commented on September 27, 2024

Hi,

POST command returns an empty string along with status code 500 "Internal Server Error", the python script works fine.

Thanks

from idrac-redfish-scripting.

nildoadao avatar nildoadao commented on September 27, 2024

Hi,

I've tried the same procedure but this time using Postman, and I'm still getting the 500 error, here's the output from Postman

image

here the headers I'm using

image

from idrac-redfish-scripting.

texroemer avatar texroemer commented on September 27, 2024

@nildoadao

For the Body, did you select "File" for a key and then choose a file? I repro the issue you were seeing but this happened because i didn't set up the Body to point to a file.

Here's from my server below showing the Body where i pointed it to a file.

image

image

from idrac-redfish-scripting.

nildoadao avatar nildoadao commented on September 27, 2024

Hi @texroemer

In fact I'was setting the file the wrong way, when i inserted File key the upload was sucessfull,

Also I was able to fix the error in my code, turns out I didn't escape properly the file and filename strings in the body request, for that reason the server didn't understand the request.

Now the updated code

    `private async Task<Uri> UploadFile(string path)
    {
        using (var request = new HttpRequestMessage(HttpMethod.Post, baseUri + FirmwareInventory))
        using (var multipartContent = new MultipartFormDataContent())
        using (var fileContent = new StreamContent(File.Open(path, FileMode.Open)))
        {
            request.Headers.Authorization = credentials;
            string etag = await GetHeaderValue("ETag", baseUri + FirmwareInventory);
            request.Headers.TryAddWithoutValidation("If-Match", etag);
            request.Headers.CacheControl = CacheControlHeaderValue.Parse("no-cache");
            fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data");
            fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
            {
                Name = "\"file\"",
                FileName = string.Format("\"{0}\"", Path.GetFileName(path))
            };
            multipartContent.Add(fileContent);
            request.Content = multipartContent;
            using (HttpResponseMessage response = await client.SendAsync(request))
            {
                if (!response.IsSuccessStatusCode)
                    throw new HttpRequestException("Falha no upload do arquivo: " + response.ReasonPhrase);

                return response.Headers.Location;
            }
        }
    }`

Thanks for your help.

from idrac-redfish-scripting.

texroemer avatar texroemer commented on September 27, 2024

@nildoadao

Good to hear you got it to work and also fixed your script, glad to help out!

from idrac-redfish-scripting.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.